Amazon API Gateway to Amazon SQS to AWS Lambda

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

This pattern shows how to deploy an AWS SAM application with Amazon API Gateway, Amazon SQS, AWS Lambda, and Amazon DynamoDB.

When an HTTP POST request is made to the API Gateway endpoint, API Gateway authorizes the request by checking Basic auth credentials for valid credentials. To do this, API Gateway calls a Lambda authorizer function that validates the request and returns whether the request is valid or not.
When the request is accepted, API Gateway forwards the message payload to an SQS queue.
A new message in the queue triggers a Lambda function. The function consumes events from the queue and inserts the payload into an Amazon DynamoDB table.
If there is any problem processing the message in the function, SQS has a DLQ (dead letter queue) configured, to which problematic messages are sent.

< 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

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Ravi Kiran Ganji

Ravi Kiran Ganji

I am a Senior Cloud Application Architect at AWS Professional Services, and Serverless Enthusiast.

Follow on LinkedIn