The Simple Notification Service (SNS) is used as a publish and subscribe messaging service. But what does it mean?
SNS is centered around topics and you can think of a topic as a group for collecting messages. Users or endpoints can then subscribe to this topic and messages or events are then published to that topic. When a message is published, all subscribers to that topic receive a notification of that message.
This helps to implement event-driven architectures within a decoupled environment. Much like SQS (Simple Queue Service), SNS is a managed service and highly scalable allowing you to distribute messages automatically to all subscribers across your environment.You can read about SQS from here.
SNS can be configured with the AWS management console, the AWS CLI or the AWS SDK.
As mentioned, SNS uses a concept of publisher and subscriber which can also be called producers and consumers respectively. It works on the same principle as SQS from this perspective.
The producers or publishers send messages to a topic which is used as the central communication control point. Consumers or subscribers of the topic are then notified of this message by of the following methods:
- EMAIL JSON
- Amazon SQS
- AWS LAMBDA
Subscribers don’t just have to be users. For example, it could be a web server and they may be notified of the message via the HTTP protocol or if it was a user you could use the email notification method.
SNS offers methods of controlling specific access to your topics through the topic policy. For example, you might want to restrict which protocol subscribers to use SMS or HTTP or HTTPS, or only allow access to this topic for a specific user.
i. SNS Developer Guide: https://docs.aws.amazon.com/sns/latest/dg/welcome.html
ii. Introduction to SNS: https://aws.amazon.com/blogs/aws/introducing-the-amazon-simple-notification-service/