Simple Notification Service (SNS)
Last updated
Last updated
When more that one receiver are interested in a message and needs to be processed, rather than using direct integration, one must prefer using SNS.
It is a managed service.
This pattern is called Pub/Sub pattern, useful when many different consumers are interested in same message.
Actors/Services responsible to send message to SNS Topic.
Actors/Services interested in receiving message from SNS Topic.
Topic is a logical access point and communication channel.
event producer
(Publisher/s) only sends message to one SNS topic.
Many services like CloudWatch Alarms, ASG, CFT changes, AWS Budgets, Lambda, DynamoDB, RDS Events, DMS etc can send data directly to SNS Topic for notifications.
event receivers
(subscriber/s) will listen to SNS topic notifications and receive all messages from this topic. Subscriber/s may receive specific messages from this topic, by filtering them.
12,50,00,000
subscribers can subscribe to one topic. Subscribers can be SQS, Email Service, Mobile Notification, HTTP endpoints, Kinesis Data Firehose (not Kinesis Data Stream) etc
About 100,000
topics can be created and limit can be increased.
There are two ways to publish,
Topic Publish (for AWS SDK)
Direct Publish (for mobile SDKs)
Create a Topic
Create a subscription
Publish to topic
Create a platform application
Create a platform endpoint
Publish to the platform endpoint
It works with Google GCM, Apple APNS, Amazon ADM to receive notifications.
This is a JSON policy used to filter messages sent to SNS topic's subscription.
If a subscription does not have message filtering then it will receive every message.
There are basically two types.
Does not ensure ordering of message delivery.
Subscribers can be HTTP/HTTPS endpoint, SQS queues, Lambda, mobile applications endpoint, Email, SMS, Kinesis Data firehose etc.
Ensures ordering of message delivery.
Subscribers can be both SQS Standard and FIFO queue.
Offers deduplication same as SQS FIFO.
Offers messaage group based ordering same as SQS FIFO.
Throughput is also similar to SQS FIFO queue.
Subscribers can only be SQS queues.
Name of fifo topic has be to suffixed with .fifo
.
Offers in-flight encryption using HTTPS API.
Can also have at rest encryption using KMS
keys.
Client-side encryption can also be done if the client wants to perform encryption/decryption itself.
AWS IAM policies
Can be used to control access to SNS API.
SNS Access policy
Can also be used to control the access, which is useful when needed to make a cross account access or control access to write to SNS Topic by other AWS services.
A typical architecuture looks like below,
SNS can be integrated with other AWS services like SQS, Lambda, Kinesis Data Firehose etc.