Working With AWS Simple Notification Service, Part 1: Basics & Setup

Amazon's message delivery service can be used to send SMS text messages and email messages, among many other things.

As you work with the various AWS services, one of the things that you are sure to notice sooner or later is that several services leverage the power of Amazon's Simple Notification Service (SNS). That being the case, I wanted to take the opportunity to show you how to set up and begin using this useful service.

For those who might not be familiar with AWS SNS, it is Amazon's message delivery service. While this service can be used to send SMS text messages and email messages, it can do a lot of other things, such as sending messages to AWS Lambda or even to a web server. In other words, SNS can allow one application to send a message to another application, or it can be set up to allow an application to send a message to a person (usually in the form of a notification).

Before I can show you how to set up AWS SNS, there are some important concepts that I need to explain. SNS is designed to send messages from publishers to subscribers (although some of the AWS documentation refers to producers and consumers instead of publishers and subscribers). A publisher is essentially just the application or service that generates a message. A subscriber is an application or service that receives, and in some cases acts on that message.

There is one last concept that I need to introduce you to before I show you how to set up AWS SNS. Publishers do not send messages directly to subscribers. Instead, publishers send messages to SNS and then SNS sends applicable messages to subscribers. Notice my use of plural words (publishers and subscribers). An organization could conceivably define any number of publishers and subscribers, and there isn't necessarily going to be a one to one relationship between the two. Multiple subscribers for example might need to receive messages from a single publisher.

In order to prevent all publishers from simply broadcasting all messages to all subscribers, SNS makes use of topics. A topic is essentially a message channel. The reason why this is important is because subscribers do not actually subscribe to publishers, but rather to topics. SNS filters the messages sent to each subscriber based on the topics that they have subscribed to.

Now that I have covered some of the basics, I am almost ready to show you how to set up SNS. Before I do however, I need to point out that there really isn't any such thing as a standard setup. In the real world, the configuration process can vary widely based on use case. My goal in this article series is to walk you through a generic setup that will give you a sense of how SNS works and how you can use it in your own organization.

So now let's take a look at how to set up SNS. The first thing that I recommend doing when you are just getting started with SNS is to create a topic. To do so, open the list of services and choose the Amazon Simple Notification Service (it's located in the Application Integration section). The initial page that is displayed contains a prompt to create a topic by entering a topic name and clicking the Next Step button, shown in Figure 1.

Figure 1: Enter a topic name and click the Next Step button.
[Click on image for larger view.] Figure 1: Enter a topic name and click the Next Step button. (source: AWS).

At this point, you will be taken to the Create Topic screen. Incidentally, this is the same screen that you will be taken to if you attempt to create a topic from the SNS dashboard. As you can see in Figure 2, the topic name is automatically populated based on what you entered on the previous screen, and most of the other fields are optional. You do however, have to tell SNS what type of topic you want to create.

Figure 2: Standard is the topic type of choice for most situations.
[Click on image for larger view.] Figure 2: Standard is the topic type of choice for most situations. (source: AWS).

In the vast majority of situations, you should choose the Standard option. The Standard option is the most versatile. It works with SQS, Lambda, HTTP, SMS, email and mobile application endpoints. In contrast, the other choice (FIFO) only works with SQS. The only advantage to choosing FIFO is that it adheres to a strict first-in, first-out message delivery order. Standard topics support more protocols and are better performing, but there is no guarantee that messages will arrive in order. When you have made your selection and configured any optional settings, click the Create Topic button at the bottom of the screen.

Now that I have introduced you to some of the basic concepts associated with SNS, it's time to complete the SNS configuration process. I will walk you through that process in Part 2.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.


Subscribe on YouTube