Amazon API Gateway to Amazon SQS to AWS Lambda

API Gateway HTTP API → SQS → AWS Lambda

Create an HTTP API that routes to SQS then Lambda

This pattern creates an Amazon API Gateway HTTP API with a send route that send message to a SQS queue. The Amazon API Gateway HTTP API has basic CORS configured. Upon receiving message, SQS will trigger a Lambda function to process the message. The function will only print the message only. The function written in Python.

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

Deploy

cdk deploy


Testing

Running following cURL command to agaist the HTTP API Endpoint:
curl -XPOST https://${HTTP_API_ENDPOOINT}/send -d'{"MessageBody":"hello"}'

Cleanup

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

Created by:

Paul Lu

Paul Lu

I am an AWS Solution Architect and a Serverless Enthusiast.

Follow on LinkedIn