Certablo
← Knowledge Base

Amazon SNS: Pub/Sub & Fanout

Push-based topic messaging for one-to-many fanout, subscription filtering, SQS buffering, and Standard versus FIFO topic semantics.

CLF-C02SAA-C03DVA-C02

Visual overview

DATA & EVENT FLOWIngest, buffer or route, transform, query, and present according to the workload
01IngestStreams · events · messages
02DecoupleQueues · topics · buses
03ProcessETL · big data · workflows
04AnalyzeSQL · warehouse · dashboards
Analytics and integration are connected but distinct: one moves and coordinates data or events; the other turns stored or streaming data into answers.
AWS SERVICE MAPFan out once, process independently

SNS publishes to durable SQS subscriptions so each consumer can process the same event independently.

Amazon SNSPublish and fan out
Amazon SQSDurable subscriber backlog
AWS LambdaIndependent consumer
EXAM-RELEVANT MECHANICS

Technical reference

SNS routing is defined by topic type, subscription protocol, and optional per-subscription filtering.

Messaging modelPublisher → topic → subscriptions

The publisher sends once to a topic; SNS independently evaluates and delivers to each subscription.

FanoutOne message → many endpoints

SQS queues are common subscribers when each downstream service needs its own durable backlog.

Filter policyAttributes or JSON body

The subscription's FilterPolicyScope determines whether policy properties are matched against message attributes or the message body.

FIFO orderingMessageGroupId

Messages in the same FIFO group maintain strict relative order while distinct groups provide parallel ordering lanes.

FIFO deduplicationExplicit ID or content-based

SNS FIFO can suppress duplicate publications within its documented deduplication interval using an ID or body-derived hash.

Delivery permissionTopic + endpoint policy/IAM

The publish and delivery path must be authorized; for SQS subscriptions, the queue policy must permit the SNS topic to send messages.

SNS separates publishers from many subscribers

Amazon Simple Notification Service (SNS) implements publish/subscribe messaging around topics. A publisher sends a message to a topic without needing to know every consumer. SNS then pushes the message to subscribed endpoints according to the subscription protocol. This one-to-many model is a natural fit for domain notifications that should trigger several independent actions.

Supported endpoint types include Amazon SQS queues, Lambda functions, HTTP(S) endpoints, and user-notification channels supported by SNS. The fanout pattern is especially robust when a topic publishes to separate SQS queues: each downstream application receives its own durable buffer and can process at its own speed without forcing the publisher to call every service directly.

Subscription filter policies route only relevant messages

By default, a subscription receives every message published to its SNS topic. A filter policy changes that behavior by matching properties from message attributes or, when the filter-policy scope is configured for it, the JSON message body. This allows one topic to serve multiple consumer interests without requiring every subscriber to receive and discard unrelated events.

Filtering is evaluated per subscription, which means two queues subscribed to the same topic can express different criteria. This differs from putting filtering logic in the publisher: the producer can publish a meaningful event once while subscriber-specific routing remains part of messaging configuration. Filters should be designed around stable event attributes rather than tightly coupling producers to individual consumer implementations.

  • Publishers address a topic, not each subscriber individually.
  • Each subscription chooses its endpoint/protocol and can have its own filter policy.
  • SNS-to-SQS fanout gives each consumer a durable, independently scalable backlog.
  • Topic and endpoint permissions must both allow the intended delivery path.

FIFO topics add ordering and deduplication where supported

SNS Standard topics target broad, high-throughput pub/sub scenarios where strict ordering is not the primary requirement. SNS FIFO topics introduce message grouping and deduplication semantics for workflows that require ordered event distribution to compatible queue subscribers. MessageGroupId defines the ordering lane, allowing independent groups to progress in parallel.

FIFO deduplication uses an explicit MessageDeduplicationId or, when enabled, a content-derived hash. Combining an SNS FIFO topic with SQS FIFO queues can preserve ordering and deduplication through the fanout path. Choose FIFO only when the business requirement actually needs these semantics; otherwise Standard topic fanout is simpler and supports a broader endpoint set.

Key takeaways

  1. 01

    SNS topics provide push-based one-to-many publish/subscribe fanout.

  2. 02

    SNS and SQS complement one another: SNS distributes while SQS durably buffers work for pull-based consumers.

  3. 03

    Subscription filter policies can match message attributes or JSON message bodies according to filter scope.

  4. 04

    FIFO topics use message groups and deduplication for ordered fanout to supported subscribers.

  5. 05

    Subscriber-specific routing belongs in subscription configuration when producers should remain decoupled.

Official AWS sources

Use these primary AWS resources for the source material behind this article and for deeper reference.