Amazon API Gateway WebSocket API to Amazon SQS to AWS Lambda

API Gateway WebSocket API → SQS → AWS Lambda

Create an API Gateway websocket API that sends events to SQS and then to Lambda

This pattern creates an Amazon API Gateway WebSocket API which sends inbound messages to an Amazon SQS FIFO queue. The queue is processed by an AWS Lambda function to return a result.
The queue acts as a buffer to alleviate traffic spikes and ensure your workload can sustain the arriving load by buffering all the requests durably. It also helps downstream consumers to process the incoming requests at a consistent pace. A FIFO (First-In-First-Out) queue is used to ensure that evens are processed in order of arrival.

< 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-apigw-websocket-api-sqs-lambda

Deploy

sam deploy --guided


Testing

See the repo for detailed testing instructions.

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Steven Warwick

Steven Warwick

Steven Warwick is a Solutions Architect at AWS. He is an engineer at heart with a passion for creating simple solutions to complex problems. He has a background in real time analytics and a passion for SaaS implementations. In his free time, he plays badminton and tinkers with IoT projects around the house.