Getting started with Amazon SNS

Table of contents
Reading Time: 2 minutes

Introduction

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.

SNS

Working Principle

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:

  1. HTTP/HTTPS
  2. EMAIL
  3. EMAIL JSON
  4. Amazon SQS
  5. AWS LAMBDA
  6. SMS
  7. Application
How SNS works

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.

References

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/

Written by 

Sarfaraz Hussain is a Big Data fan working as a Senior Software Consultant (Big Data) with an experience of 2+ years. He is working in technologies like Spark, Scala, Java, Hive & Sqoop and has completed his Master of Engineering with specialization in Big Data & Analytics. He loves to teach and is a huge fitness freak and loves to hit the gym when he's not coding.