Add Lambda Authorizer Output to the Input of other Lambda

Viewed 457

Background

I currently have an authorizer that takes a JWT token and decodes it and checks if valid or not to build a policy document, then that is used to grant or deny access to API endpoints.

Currently, the endpoints are using query strings as parameters to grab data.

Problem

I need to make it so that the values for the user and email etc are the ones that come from the decodes JWT Token. How do I pass the decodes values to the input of the other lambda functions?

I am open to suggestions, or links, or at least a point in the right direction.

1 Answers

Per the documentation, you need to include those in the context section of the authorizer response. Then you will need to map the context values in your API Gateway mapping template.

If you are using Lambda Proxy Integration then the context returned from the Authorizer function will be in the event.requestContext.authorizer. That does not appear to be documented anywhere, but I always recommend printing the entire event object to your logs when you first start working on a Lambda function so you can see exactly what is being passed into it.

Related