Amazon API Gateway HTTP API to AWS Lambda

API Gateway REST API → AWS Lambda

Create an Amazon API Gateway REST API with an IAM authorizer

This patterns creates a REST API and a Prod stage with a single / resource with a GET method. IAM is configured as the authorization method, and a Lambda integration with is defined with caller credentials enabled.
Two IAM users are created, one to test the correct required permission and another with insufficient permissions. Both contain policies with scoped down actions and resources.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Launch Stack

Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-iam

Deploy

sam deploy --guided


Testing

1. Once the application is deployed, retrieve the HttpApiEndpoint value from CloudFormation Outputs. Either browse to the endpoint in a web browser or call the endpoint from Postman.
2. See the repo for additional testing notes.

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Rafael Liu

Rafael Liu

Rafael Liu is passionate about all things software engineering and solving hard problems. He helps customers design and build architectures and processes, often leveraging DevOps and Serverless. Unashamedly a Java fan, Linux and Open Source enthusiast.