Amazon API Gateway to AWS Lambda

API Gateway REST API → AWS Lambda

Create an Amazon API Gateway to AWS Lambda REST API

This pattern in CDK offers a boilerplate to generate an Amazon API Gateway REST API endpoint with a a greedy proxy ('{proxy+}') and 'ANY' method from the specified path, meaning it will accept by default any method and any path. The Lambda function provided in TypeScript only returns the path.

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

Deploy

npm run deploy


Testing

After deployment, the output shows the API Gateway URL with the Lambda Integration, for example: ServerlessLandApi.ServerlessLandEndpointC36EEEC4 = https://.execute-api.us-east-1.amazonaws.com/prod/.
Accessing the URL in a browser, you see:
Hello, your path is: "/".
This page logs any path you type after "/". You can use this as a starting point as a general purpose endpoint for various types of applications.

Cleanup

1. Delete the stack: npm run destroy
2. Confirm the removal and wait for the resource deletion to complete.

Additional resources

Created by:

Ibrahim Cesar

Ibrahim Cesar

/ɪ́brəhɪjm/ is a Technology Director at a news startup media in Brazil. Work with frontend, web development and serverless.