Websocket Amazon API Gateway with an AWS Lambda Authorizer and mapping template

Amazon API Gateway WebSocket → AWS Lambda → Amazon DynamoDB

Create a Websocket API with a Lambda Authorizer and an AWS Lambda in the back-end.

This projects demonstrates how to use a WebSocket API with an AWS Lambda Authorizer
The WebSocket API does not have a Proxy integration with the back-end Lambda Function written NodeJs 22, instead it is using a mapping template that forwards the main information of the request.
The Connection ID is stored in a Amazon DynamoDB table and the Lambda Function sends a response to the websocket API through the endpoint URL

< 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-websocket-mapping-template-authorizer

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Alice Goumain

Alice Goumain

Cloud Support Engineer in Serverless @ AWS

Follow on LinkedIn