Amazon API Gateway REST API with AWS Lambda token authorizer

Amazon API Gateway → AWS Lambda

Create an API with a mapping template that enriches the request with additional data from Lambda Token Authorizer.

This SAM template creates an API that uses additional logic from the Lambda token authorizer to add data to the request.
The data is passed to the HTTP endpoint in the form of a custom header.
This aproach can be used to inject data that downstream legacy systems expect and that is dependent on data that is available to authorizer.
The HTTP endpoint in the example returns a response showing the headers that are received.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-lambda-authorizer-custom-header

Deploy

sam deploy


Testing

Once the application is deployed, retrieve the API URL and a request from Postman or from a terminal using the curl command with an AuthorizationToken header of 'allow'.

Cleanup

Delete the stack: sam delete.

Created by:

Shaun Guo

Shaun Guo

Shaun is a Senior Technical Account Manager at Amazon Web Services based in Australia

Follow on LinkedIn