Amazon SNS
AWS SNS is a fully managed pub/sub messaging service.
It lets you decouple microservices, distribute messages to multiple subscribers, and send notifications via multiple protocols (HTTP/S, SQS, Lambda, SMS, email, mobile push, and more).

Key features
- Multi-protocol delivery (HTTP/S, SQS, Lambda, SMS, Email, Application endpoints).
- Topic-based publish/subscribe model for fan-out.
- Message filtering by attributes at the subscription level.
- FIFO topics (ordering and exactly-once semantics) in addition to standard topics.
- Message attributes and structured message bodies.
- Delivery retry policies and optional dead-letter queues for undelivered messages.
- Server-side encryption (SSE-KMS) and fine-grained access control via topic policies/IAM.
- Mobile push support (APNs, FCM, ADM, etc.) through platform application endpoints.
- Integration with other AWS services (SQS, Lambda, EventBridge, CloudWatch, CloudTrail).
Common use cases
- Fan-out notifications to multiple consumers (SNS → SQS → workers).
- System alerts and monitoring notifications (CloudWatch alarms → SNS).
- Mobile push notifications and SMS alerts.
- Triggering serverless functions for near-real-time workflows.
- Cross-account or cross-region event distribution.
Basic CLI examples
Create a topic:
aws sns create-topic --name order-events
Subscribe an SQS queue to a topic:
aws sns subscribe \
--topic-arn arn:aws:sns:us-east-1:123456789012:order-events \
--protocol sqs \
--notification-endpoint arn:aws:sqs:us-east-1:123456789012:order-queue
Publish a message with attributes:
aws sns publish \
--topic-arn arn:aws:sns:us-east-1:123456789012:order-events \
--message "OrderCreated" \
--message-attributes '{"orderType":{"DataType":"String","StringValue":"B2C"}}'
Create a FIFO topic:
aws sns create-topic --name order-events.fifo --attributes FifoTopic=true
Delivery semantics & retries
- Standard topics: at-least-once delivery; duplicates possible; no global ordering.
- FIFO topics: deduplication and message ordering when using MessageGroupId.
- SNS retries according to protocol. For HTTP/S it will retry with backoff. For SQS and Lambda delivery is reliable; failed deliveries can be captured in DLQs.
Best practices
- Use SNS → SQS fan-out for reliable, durable consumer processing.
- Enable subscription-level filtering to reduce unnecessary processing.
- Use DLQs for critical delivery paths to capture undelivered messages.
- Prefer FIFO topics only when strict ordering and deduplication are required.
- Apply topic policies and IAM least-privilege for publish/subscribe operations.
- Encrypt sensitive messages with SSE-KMS.
- Monitor CloudWatch metrics: NumberOfMessagesPublished, NumberOfNotificationsDelivered, NumberOfNotificationsFailed, PublishSize.
Limits & considerations
- Message size limit: 256 KB (use S3 pointers for larger payloads).
- SMS has regulatory and throughput considerations per region.
- Mobile push may require platform credentials (APNs, FCM).
- SNS pricing: pay per request and per SMS or mobile push delivery (region dependent).
