AWS in 1 Min · Episode 128

Amazon SNS explained: pub/sub on AWS

Publish once, deliver to many. Watch the one-minute video, then read the details.

David Gomez1:14 video · 3 min read

"To notify five systems, call all five." That works until there are six, or one of them is down, or a new team wants the same event. With publish-subscribe (pub/sub), the sender publishes once and doesn't even need to know who is listening. On AWS, the classic pub/sub service is Amazon Simple Notification Service (SNS).

Publishers, topics, subscribers

  • A topic is a named channel, like order-placed.
  • A publisher sends a message to the topic, once.
  • Subscribers register with the topic. SNS pushes a copy of each message to every one of them, in parallel.

Adding a new consumer means adding a subscription. The publisher's code doesn't change. That is the real win: teams can react to the same event without coordinating releases.

Who can subscribe

SNS delivers to two broad groups:

  • Application-to-application: Amazon SQS queues, AWS Lambda functions, HTTP/HTTPS endpoints and Amazon Data Firehose.
  • Application-to-person: email, text messages (SMS) and mobile push notifications.

A typical setup: a CloudWatch alarm publishes to a topic, which emails the on-call team and triggers a Lambda function that opens a ticket.

Push, not pull

The key difference from a queue: SNS pushes. Subscribers don't pull from a backlog at their own pace. SNS retries deliveries that fail, and you can attach a dead-letter queue to a subscription for messages it gives up on, but it is not a buffer for slow consumers.

If a consumer needs to work at its own speed, survive downtime or retry safely, put an SQS queue behind the topic and let the worker read the queue. That combination, SNS plus SQS, is called fan-out, and it is the subject of the next episode.

Filter policies

By default every subscriber gets every message. A filter policy on a subscription lets it receive only what it needs, based on the message attributes or on the JSON body. For example, the fraud-check service subscribes only to orders over a certain amount, and the shipping service only to orders with physical items. Filtering at the topic saves each consumer from receiving and discarding messages it doesn't care about.

SNS also offers FIFO topics for when order and de-duplication matter; they deliver to SQS queues.

Common mistakes

  • Subscribing a slow service directly to a busy topic, then wondering why messages fail during spikes. Put a queue in between.
  • Publishing everything to one giant topic without filters, so every consumer does its own filtering.
  • Forgetting that HTTP and email subscriptions must be confirmed before they receive anything.

Where AI fits

Pub/sub is a clean way to run several AI tasks on the same event. Say a new support ticket arrives. Publish it once to a topic, and let three subscribers work in parallel: one Lambda function summarizes it, another classifies its urgency, and a third drafts a reply with a model on Amazon Bedrock. Adding a fourth task later, such as sentiment tracking, is just one more subscription. For heavy or rate-limited model calls, put a queue behind each subscription.

Quick recap

  • Publish once to a topic; SNS pushes a copy to every subscriber.
  • Subscribers: SQS, Lambda, HTTPS, Firehose, email, SMS, mobile push.
  • Filter policies decide what each subscriber gets; add a queue when a consumer needs a buffer.
AWS in 1 Min #128 · 1:14

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS