AWS Builder Center
Amazon SNS: From First Notification to Alert System

Amazon SNS: From First Notification to Alert System

A hands-on walkthrough of Amazon SNS, from publishing your first email notification to building a multi-subscriber fanout alert system for CI/CD pipelines.

Notifications are a small but important part of many applications.
Imagine a QA team running automated tests for an application. If a test fails, the development team needs to know about it. Similarly, an application may need to notify a team when an important event occurs, such as a deployment failure, system error, or business event.
One approach is to build notification logic separately for each application and each destination. As the system grows, this can become difficult to manage.
Amazon Simple Notification Service (Amazon SNS) provides a simpler way to distribute messages and notifications.
In this article, we'll start with a basic SNS notification and then see how the same concept can be extended into a simple application alert system.

What is Amazon SNS?

Amazon Simple Notification Service (Amazon SNS) is a fully managed publish/subscribe messaging service.
The basic idea is:
Publisher → SNS Topic → Subscribers

A publisher sends a message to an SNS topic. SNS then delivers that message to the subscribers associated with the topic.
For example:
Application
|
| Publish message
v
SNS Topic
|
+--------> Email
|
+--------> Lambda
|
+--------> SQS

The application does not need to send the same message independently to every destination. It publishes the message to the topic, and SNS handles the distribution.

Why Do We Need SNS?

Consider a simple application that needs to notify a development team whenever an important error occurs.
Without a messaging service, an application might need to contain logic such as:
If error occurs
→ send email
→ notify another service
→ send message to another system

As more notification destinations are added, this logic can become tightly coupled with the application.
With SNS, the application can publish an event to a topic:
Application
|
v
SNS Topic
|
+----> Email
+----> Lambda
+----> SQS

This separates the application that generates the event from the systems that consume the notification.

Understanding the Three Main SNS Concepts

Before creating our first notification, let's understand three important concepts.

1. Publisher

A publisher is the application or system that sends a message.
Examples include:
  • Backend application
  • Monitoring system
  • CI/CD pipeline
  • AWS service
  • Script
For our example, imagine that a QA system detects a failed test. The QA system becomes the publisher.

2. Topic

A topic is a communication channel where messages are published.
For this article, we'll use:
application-alerts

The publisher sends its message to this topic. The topic doesn't represent a single email address or application. It acts as a central point through which messages can be distributed to subscribers.

3. Subscriber

A subscriber is a destination that receives messages published to the topic.
Depending on the use case, subscribers can include destinations such as:
  • Email
  • Amazon SQS
  • AWS Lambda
  • HTTP/HTTPS endpoints
  • Other supported endpoints
So our basic flow becomes:
Publisher → SNS Topic → Subscriber


Let's Create Our First SNS Notification

Now let's move from theory to practice. Our goal is simple:
Create an SNS topic, subscribe an email address, and publish a test notification.
This can be done using the AWS Management Console.

Step 1: Create an SNS Topic

Open the Amazon SNS console and navigate to:
SNS → Topics → Create topic

For this example, create a topic named:
application-alerts

For a simple notification example, a Standard topic is sufficient. After creating the topic, AWS provides an ARN for it. An ARN is the unique identifier used to refer to an AWS resource. It will look similar to:
arn:aws:sns:region:account-id:application-alerts


Step 2: Create an Email Subscription

Creating the topic doesn't automatically send messages anywhere. We need to add a subscriber.
From the SNS console, create a subscription for the topic. Choose:
Protocol: Email

Then enter an email address that you can access, for example:
your-email@example.com

Create the subscription. SNS will send a confirmation request to the email address. Open the email and confirm the subscription. Once the subscription is confirmed, the email address can receive messages published to the topic.
Our architecture now looks like this:
+----------------------+
| SNS Topic |
| application-alerts |
+----------+-----------+
|
v
+---------------+
| Email |
| Subscriber |
+---------------+


Step 3: Publish Your First Message

Now we can send our first notification. Open:
SNS → Topics → application-alerts

Choose the option to publish a message. For the subject, enter:
Test Notification

For the message, you can use:
Hello! This is my first Amazon SNS notification.

Publish the message. SNS will send the message to the confirmed email subscriber. Check your inbox — you should receive the notification.
🎉 You've just published your first SNS message.

What Happened Behind the Scenes?

Let's simplify what happened. We started with the publisher — you — and published a message to  application-alerts , our SNS topic. SNS then distributed the message to the email subscriber.
So the complete flow was:
Publisher
|
| Publish message
v
SNS Topic
|
| Deliver message
v
Email Subscriber

This simple publisher → topic → subscriber model is the foundation of SNS.

From Notification to Alert System

Now let's make the example more practical. Imagine a development team has an automated QA process. Whenever a new version of an application is deployed, automated tests are executed.
If everything passes:
Deployment → QA Tests → SUCCESS

But if the tests fail:
Deployment → QA Tests → FAILED

The team could automatically publish an alert to an SNS topic. The architecture could look like this:
+----------------+
| QA System |
+-------+--------+
|
| Test Failed
v
+---------------------+
| SNS Topic |
| application-alerts |
+----------+----------+
|
v
Developer Email

The important idea is that the QA system only needs to publish the alert to the SNS topic. The notification destination can be managed separately through SNS subscriptions.

Making the Alert More Useful

A useful alert should contain enough information for someone to understand what happened. Instead of sending:
Test failed.

we could send:
Application: Payment Service
Environment: QA
Build: #248
Status: FAILED

Please check the latest test results and application logs.

This is much more useful to a developer receiving the notification. The exact message format will depend on the application and the information available to the publisher.

One Topic, Multiple Subscribers

Here's where SNS becomes particularly useful. A single topic can have multiple subscribers, for example:
SNS Topic
|
+--------------+--------------+
| | |
v v v
Email Lambda SQS

Suppose a QA failure occurs. The same event could potentially be used for different purposes:
Email — A developer receives an alert.
AWS Lambda — A Lambda function can process the event automatically.
Amazon SQS — A queue can receive the message so another application or worker can process it.
This pattern allows one publisher to distribute messages to multiple consumers.

What is Fanout?

The previous architecture is an example of a fanout pattern. The idea is:
One Message
|
v
SNS Topic
/ | \
/ | \
v v v
Email Lambda SQS

Instead of the publisher knowing about every destination, it publishes once to the SNS topic. SNS handles the distribution to the subscribed destinations. This becomes especially useful when a system needs to notify or trigger multiple independent components.

SNS and SQS: What's the Difference?

SNS and SQS are both commonly used in AWS messaging architectures, but they solve different problems.
A simple way to think about SNS is:
Publish → Distribute

While SQS is commonly used as:
Queue → Process


SNS

SNS is useful when a message needs to be distributed to multiple subscribers.
SNS
|
+------+------+
| | |
v v v
Email Lambda SQS


SQS

SQS provides a queue that consumers can process.
Producer → SQS Queue → Consumer

They can also be combined. For example:
Application
|
v
SNS Topic
|
+-------> Email
|
+-------> SQS Queue
|
v
Worker

This gives us both notification and asynchronous processing capabilities.

Using SNS from an Application

So far, we've used the AWS Management Console. In a real application, a program can publish messages to an SNS topic. Conceptually:
if operationFailed:
publish alert to SNS

The application doesn't have to directly manage every notification destination. Instead:
Application
|
v
SNS Topic
|
+------> Email
+------> Lambda
+------> SQS

Messages can be published using AWS SDKs, the AWS CLI, APIs, or the AWS Management Console.

Publishing a Message with the AWS CLI

Once you're comfortable with the console, you can also publish a message using the AWS CLI:
aws sns publish \
--topic-arn arn:aws:sns:REGION:ACCOUNT_ID:application-alerts \
--message "QA test failed. Please check the latest build."

Replace the topic ARN with the ARN of your own SNS topic. This type of approach can be useful when integrating SNS into scripts, automation, or CI/CD workflows.

A Simple CI/CD Alert Flow

Let's combine what we've learned into one practical example. Imagine a CI/CD pipeline for a backend application. The flow could be:
Code Change
|
v
Build
|
v
Automated Tests
|
+------------------+
| |
v v
SUCCESS FAILED
|
v
SNS Topic
|
v
Developer Email

If the tests fail, the pipeline can publish an alert. The developer receives the notification and can investigate the failure. This is a simple example, but the same idea can be extended with additional subscribers and AWS services.

Why Separate the Notification Layer?

One advantage of using a messaging service is separation of responsibilities. The application can focus on producing an event:
"Build failed"

SNS can focus on distributing that message. The subscribers can decide what to do with it. For example:
Application
|
| Event
v
SNS
|
+---- Email → Notify developer
|
+---- Lambda → Perform automated action
|
+---- SQS → Queue for processing

This can make an architecture easier to extend, because adding another subscriber does not necessarily require changing the original publisher.

Important Things to Remember

1. Creating a topic is not enough

An SNS topic needs subscribers if you want messages to be delivered to an endpoint.

2. Confirm email subscriptions

When using an email endpoint, the subscription needs to be confirmed before it can receive notifications. If you don't receive the expected message, checking the subscription status is a good first step.

3. SNS and SQS are different

Remember the basic distinction:
SNS → distribute messages SQS → queue messages for processing
They can also work together.

4. Choose the appropriate topic type

SNS provides different topic options for different requirements. For a simple notification example, a Standard topic is enough. When designing a production system, consider the requirements around ordering, delivery behavior, throughput, and message handling before choosing the topic type.

5. Keep sensitive information out of resource names

Avoid putting confidential information or personally identifiable information into SNS topic names or other resource names. Use meaningful but non-sensitive names such as:
  •  application-alerts 
  •  order-events 
  •  deployment-notifications 

6. Clean up resources after experimenting

If you're following this tutorial only for learning, remember to remove resources you no longer need, for example:
  • SNS Topic
  • Email Subscription
Keeping your AWS environment clean is a good habit when experimenting.

What We Learned

Let's quickly recap our journey. We started with a simple notification:
Publisher → SNS Topic → Email

Then we extended the idea:
SNS Topic
/ | \
/ | \
v v v
Email Lambda SQS

Along the way, we learned:
  • What Amazon SNS is
  • What a publisher is
  • What an SNS topic is
  • What a subscriber is
  • How to create an SNS topic
  • How to subscribe an email address
  • How to publish a message
  • How SNS can distribute messages to multiple destinations
  • What the fanout pattern means
  • How SNS differs from SQS
  • How SNS can be used in application and CI/CD alert scenarios

Final Thoughts

Amazon SNS is a good example of how a relatively simple AWS service can solve a common application problem. We started with something as simple as:
You → SNS → Email

But the same concept can grow into:
Application
|
v
SNS Topic
| | |
v v v
Email SQS Lambda
|
v
Worker

The key concept to remember is:
Publish a message to a topic, and let SNS distribute it to the subscribers that need it.
If you're new to AWS, a good way to learn SNS is to start small:
  1. Create a topic.
  1. Add an email subscription.
  1. Confirm the subscription.
  1. Publish a message.
  1. Add another type of subscriber when you're ready.
Once this publisher → topic → subscriber model becomes clear, it becomes much easier to understand how SNS can fit into larger event-driven architectures.
Start with one notification. Then build from there.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article