Amazon API Gateway REST API to AWS Lambda

API Gateway REST API → AWS Lambda

Create an Amazon API Gateway REST API that invokes an AWS Lambda function

This pattern deploys an Amazon API Gateway REST API with a default route and basic CORS configuration. The default route is integrated with an AWS Lambda function written in TypeScript. The function logs the incoming API event (v2) and context object to an Amazon CloudWatch Logs log group and returns basic information about the event to the caller.

< 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-sls

Deploy

serverless deploy --verbose


Testing

1. Once the application is deployed, retrieve the ServiceEndpoint 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: serverless remove --verbose.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Dmitry Gulin

Dmitry Gulin

Modernization Architect, AWS

Follow on LinkedIn