Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

API WebSocket to SNS with request validation

Created with SnapAmazon API GatewayAmazon SNS

Create a WebSocket API to send notification via SNS topic with request validation

This sample project demonstrates how to use an Amazon API Gateway WebSocket API to integrate with Amazon Simple Notification service (SNS) to send notifications. This pattern also implements data validation in the WebSocket API using a model in API Gateway.
This pattern is utilizing native AWS Integration between WebSocket API Gateway and SNS. A request template is used in WebSocket integration to map the input to SNS payload.
This pattern is also a workaround to invoke AWS services in WebSocket API which requires the Content-Type header to be application/x-www-form-urlencoded. By default, WebSocket APIs do not support overriding headers from AWS console.
This pattern deploys one API Gateway and one SNS topic.

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/apigw-websocket-api-sns-terraform

Deploy

terraform initterraform apply


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

terraform destroy -target aws_apigatewayv2_route.send_order
terraform destroy
terraform show

Dushyant Pal

Presented by Dushyant Pal

Cloud Engineer, Serverless team at AWS Sydney, Australia

Follow on LinkedIn