Amazon API Gateway to AWS Lambda

API Gateway REST API → AWS Lambda

Create an Amazon API Gateway to AWS Lambda HTTP API

This pattern creates an Amazon API Gateway API and an AWS Lambda function using AWS Cloud Development Kit (AWS CDK) in Python. This template also has a sample CORS configuration. The sample application was developed in Python and it shows some context, event and environment variables properties.

< 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-http-api-lambda-cdk

Deploy

cdk deploy


Testing

Run the following command to send an HTTP GET request to the HTTP APIs endpoint. Note that you must edit the {api_endpoint} placeholder with the URL of the deployed HTTP APIs endpoint. This is provided in the deployment outputs.
curl -H "Origin: https://www.example.com" "{api_endpoint}?path=parameter" --verbose
The output will show a JSON object created by the sample application.

Cleanup

1. In the source folder, from the command line enter:
npx cdk destroy --app 'ts-node .'
2. Confirm the removal and wait for the resource deletion to complete.

Additional resources

Created by:

Eduardo Bortoluzzi

Eduardo Bortoluzzi

I am an AWS Cloud Applications Architect at the Professional Services team. I have been working with Cloud Computing since 2008 and I recommends serverless every time I can.