# Amazon SNS

> One message in, many copies out: a megaphone for systems.

- Level: Intermediate
- Topics: AWS
- URL: https://tidbit.legios.com.ar/amazon-sns/
- In Spanish: [Amazon SNS](https://tidbit.legios.com.ar/es/amazon-sns/)

**Amazon SNS** (Simple Notification Service) is a publish/subscribe service. You create a **topic**, several subscribers sign up to it, and every message published to the topic is delivered to all of them at once. A subscriber can be an AWS Lambda function, an Amazon SQS queue, an HTTPS endpoint, an email address or a phone number (SMS).

The difference with a queue: Amazon SQS hands each message to one consumer; a topic copies each message to every subscriber. The two are often combined: SNS fans an event out to several SQS queues, each owned by a different team, and each team processes it at its own pace.

Example: when an order is paid, the shop publishes 'order 4521 paid' to a topic. The warehouse queue receives it, the invoicing function receives it, the analytics pipeline receives it, and the customer gets an SMS. The checkout code published once and has no idea who is listening.

SNS is also how Amazon CloudWatch alarms reach people: the alarm publishes to a topic, and the topic emails or texts whoever is on call.

## An analogy

A WhatsApp broadcast list. You write the message once; every contact on the list gets their own copy and does whatever they want with it.

## Keep in mind

- Publish once, deliver to every subscriber at the same time (fan-out).
- Subscribers can be code (Lambda, SQS, HTTPS) or people (email, SMS, push notifications).
- SNS does not keep messages for later: if nobody is subscribed when you publish, the message is gone.
- Filters let each subscriber receive only the messages it cares about.

## Go deeper

- [What is Amazon SNS? (official docs)](https://docs.aws.amazon.com/sns/latest/dg/welcome.html)
- [Amazon SNS product page](https://aws.amazon.com/sns/)

## Related terms

- [AWS Lambda](https://tidbit.legios.com.ar/aws-lambda/): Run a piece of code only when something happens, with no server to manage.
- [Amazon SQS](https://tidbit.legios.com.ar/amazon-sqs/): A waiting line for messages between programs, so none of them gets lost.
- [HTTPS](https://tidbit.legios.com.ar/https/): The padlock in your browser: web traffic nobody in between can read.
- [Amazon CloudWatch](https://tidbit.legios.com.ar/amazon-cloudwatch/): The dashboard and alarm system that watches everything running in your AWS account.
