API WebSocket to Amazon SNS with request validation

Amazon API Gateway → Amazon SNS

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

This sample project demonstrates how to use WebSocket API to integrate with Amazon Simple Notification service (SNS) to send notifications. This pattern also implements data validation in WebSocket API using model in API Gateway.
This pattern is utilizing native AWS Integration between WebSocket API Gateway and SNS. 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 Content-Type header to be application/x-www-form-urlencoded. By default, WebSocket APIs do not support overriding headers from AWS console by default
This pattern deploys one API Gateway and one SNS topic.

< 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-api-sns

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

sam delete

Created by:

Bharat Sahni

Bharat Sahni

Bharat Sahni is a Cloud Support Engineer 2 in Serverless team at AWS based in BLR, India.

Follow on LinkedIn