Saturday 1 July 2017

Using AWS Simple Notification Service (SNS)

SNS is an AWS service that facilitates and coordinates the sending of messages in forms such as text or email to subscribing endpoints/clients.
In SNS terminology there are two types of clients publishers and subscribers.

Publishers communicate with the subscribers by producing and sending a message to a topic which is a logical communication channel.
Subscribers receive the message over one of the supported communication channels when they are subscribed to the topic.

SNS notifications are commonly used in conjunction with cloudwatch alarms to notify users in case of a threshold breach or critical alarm.

Now I'll demonstrate using SNS by configuring a sample topic, adding a subscriber to that topic and then send a test notification to that subscriber.

To locate SNS, you can type SNS in the search box just below the heading AWS services within the AWS services dashboard and click on it to go to the SNS section.



Once selected, you will be brought to the SNS dashboard which is shown in the following screenshot.



From here click on create topic. You will now be asked to enter a topic name and display name. Note that display name is required only if you are using SMS but here I'll enter one anyway.



Once we've successfully created out topic we'll be dropped to the topics section of the SNS dashboard which will show some information about our topic and also list the subscribers who'll be consuming the content from this topic.



Now we'll add a subscriber to this topic. For this click on create subscription.
Here the topic ARN will be pre-populated. We'll need to select a protocol and mention an endpoint for the subscriber. For example if we select



Once done we'll be brought back to the AWS topic section and under subscriptions we can now see a "pending confirmation" under the subscription id for the subscription I just added.


This is because AWS SNS will not send notifications to an endpoint until the endpoint accepts to receive notifications from SNS.

Now I've received an email from SNS on my email id requesting me to confirm that I'd like to receive SNS notifications from the topic I created.



When I open the email I found a link to confirm my subscription. I clicked on confirm subscription.


After clicking on confirm subscription we'll be shown the following message as an acknowledgement.


Now if we go to the topic section of our SNS dashboard again and check under subscription we'll no longer see a "pending confirmation".


To validate the functioning of our setup I'll send a test notification to this subscriber.

For this click on publish to topic under the topic section of the SNS dashboard.



We'll now be shown the below template where we can type our message to be sent.


Once you've completed typing the message click on publish message.

Now when I checked my email again I observed that I had received the SNS notification that I had published earlier.



This successfully validates the functioning of our SNS setup.

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...