Amazon SNS
for simple notification service
and is a fully managed pub/sub
service provided by AWS what
is pub/sub pub/sub stands for publish/
subscribe and it’s an architectural pattern
where you have one entity send a message into a predefined topic
and have many other entities listening for messages on
that topic in other words one entity publishers and
at least one other entity
is subscribed to messages
in that topic this becomes really useful in our project where
we will potentially have many services and we want these services
to stay in sync with one another by sending messages this creates
a pattern called fan-out one service generates a message
and it gets automatically replicated out to whoever
is listening SNS also becomes useful because it handles
the message sending to all the subscribers on an individual level
this is important because if I have saved 200 subscribers and only one of them returns an error
I want to Amazon SNS to retry stealing –
only that one errant subscriber not all 200 to bring
this all home a little in the server this application world
the publishers and subscribers are all member functions
so we can have a lambda function publish a message into
a topic and have a bunch of other lambda functions
in other server serves subscribe to that event lastly SNS
is built on use so if no messages are sent you pay nothing
and there is a generous free tier as well so while we
are esting out our application we should see no charges
to get the most out of this article you should already
have an account with Amazon Web Services have signed up for Amazon SNS
and have an interest in sending notifications
to applications and users and/or devices what is
Amazon SNS Amazon simple notification service
is a web service that enables applications end-users
and devices to instantly send and receive notifications
from the cloud a topic is an access point identifying
a subject or event type for publishing messages
and allowing clients to subscribe for notifications
Amazon SNS a single topic and support notification
deliveries over multiple transport protocols subscribers
or clients interested in receiving notifications from topics
of interest they can directly subscribe to a topic
or be subscribed by the topic owner subscribers specify
the protocol format and endpoint URL email address etc.
for notifications to be delivered upon receiving
a subscription request Amazon SNS will send a confirmation message
to the specified endpoint asking the
opting in can be done by calling
an API using a command line tool
or for email notifications simply
clicking on a link when topic owners have an update they publish a message to the topic which immediately triggers Amazon SNS to deliver this message
to all subscribers in this video we will create
a topic subscribe to the topic publish a message
to the topic unsubscribe from the topic and delete
the topic using the AWS management console creating
a topic to create a topic go to the AWS management console
webpage in the Amazon SNS tab click create new topic
the create new topic dialog box appears enter a topic name
in the topic name field click create topic the
new topic appears in the topic details page subscribing
to a topic to receive messages published to a topic you have
to subscribe an endpoint to topic an endpoint is
a web server an email address or an S qsq that
can receive notification messages from Amazon as an S once you subscribe in and point
to a topic and the subscription
is confirmed the endpoint will receive
all messages published to that topic to subscribe to
a topic by email click on the link to the topic you just
created click the create new subscription button the subscribe
dialog box appears select email in the protocol drop-down
box enter an email address you can use to receive
the notification in the endpoint click Subscribe go to your
email client and open the message from AWS notifications
then click the link to confirm your subscription your
web browser displays a confirmation response from Amazon SNS publishing
to a topic publishers send messages
to topics once a new message is published
Amazon SNS attempts to deliver that message
every endpoint that is subscribe to the topic
to publish a topic click the topic you want to publish
to under my topics in the navigation pane the topic details
page opens click the public topic button the publish
dialog box appears enter a subject line for your message
in the subject field enter a brief message in the message
field click publish message a confirmation dialog
box appears click close to close the confirmation
dialog box you can now use your email client
to open the message from AWS notifications and read the message
unsubscribing from a topic to unsubscribe from
a topic click my subscriptions in the navigation pane the my subscription page opens click the checkbox next to the topic in the subscription list click the delete subscriptions button the delete selected subscriptions confirmation dialog box appears click yes delete deleting a topic click the topic you want to delete under my topics in the navigation pane the topic details page opens click the all topic actions drop-down list and select delete topic the delete topic confirmation dialog box appears click yes delete when you delete a topic you also delete all subscription to that topic you