SNS is a fully managed pub/sub message delivery service hat enables you to decouple microservices, distributed systems, and serverless applications.
Features
SNS can be used for event notification, notifying admins of system alerts (CloudWatch), mobile push (no polling) notification.
- Messages (<= 256 KB) are sent to a topic and delivered to subscribers.
- Typically, JSON key-value pairs
- Resource policies define who can access a topic.
- For some AWS services (EC2 or Lambda), IAM roles are used.
SNS Components
- Topic
- A configuration for SNS. Messages are sent to a topic.
- FIFO vs. Standard
- In most cases, you can use the standard topic
- If you need the strictly-preserved message ordering, you can use the FIFO topic.
- A subscriber to a FIFO topic must be SQS.
- Subscriber
- Endpoints that receive a message
- HTTP, Email, SQS, Lambda, or Mobile push notification
- Message Filtering
- A subscriber can filter messages from the topic by assigning a filter policy.
- Publisher
- An entity that sends messages to a topic
- Custom Application, S3, CloudWatch, or CloudFormation
SNS Benefits
- SNS Can be used with the AWS Console, API, CLI, and multiple SDKs.
Use Cases
- Fan Out
- Push once in SNS, fan out to other services for parallel processing (Amazon SQS queues, AWS Lambda functions, and HTTP/S webhooks)
- ex) S3 event -> SNS -> SQS Queues
- Notifications
- SNS can be used to send notifications to end users using mobile push, SMS, and email.
Security
- Encryption
- In-transit: HTTPS
- At-rest: KMS
- IAM Policies
- Control access to SNS APIs
- SNS Access Policies
- Cross-account access to SNS Topics
- Control other AWS Services (such as S3) to send a message to an SNA Topic
Redrive to Dead Letter Queue (DLQ)
- SNS Messages that are not delivered will be discarded after the delivery retries.
- You can redirect undelivered messages to the DLQ.
- Redirect Policy
- deadLetterTargetArn
- DLQ is attached to the SNS subscription level, not a target level.
