Amazon API Gateway to Amazon SQS to AWS Lambda to Amazon DynamoDB

Amazon API Gateway → Amazon SQS → AWS Lambda → Amazon DynamoDB

This pattern shows how to deploy a CDK application with API Gateway, SQS, Lambda, and DynamoDB.

This pattern deploys an Amazon API Gateway HTTP API with a route/submit configured with basic authentication.
On receiving a request, API Gateway will invoke a Lambda authorizer which validates the request and returns a policy informing API Gateway to accept or deny the request.
When the request is accepted, API Gateway sends the message payload to a queue in SQS. SQS uses another queue as a dead-letter queue to send the messages in case of continued failures to process the messages from the downstream Lambda function.
The messages from SQS are posted to a Lambda function to process them.
The Lambda function receives the messages from SQS and saves them into a DynamoDB table.

< 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-sqs-lambda-ddb-cdk

Deploy

cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: cdk destroy.

Created by:

Philippe Bosle

Philippe is a Technical Account Manager at Amazon Web Services based in Switzerland.

Follow on LinkedIn