Invoking Lambda Functions

You can invoke a Lambda function from a browser in two ways. The first way is to use the AWS SDK. The second is via the Amazon API Gateway. First, we’re going to see how to invoke Lambda functions from the browser, using the AWS SDK and the Cognito credentials issued to the user.

By adding a new policy to our authenticated Cognito role, we can invoke Lambda functions directly from the browser without going through a public HTTP interface. As long as users have the proper credentials that let them assume the role, they can perform any operation listed in the policy. The particular operation we want to perform is named invoke. To perform this operation, you need to create an instance of the Lambda class from the AWS library. ...

Get Serverless Single Page Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.