Amazon Simple Notification Service (Amazon SNS) is a fully managed service that provides message delivery from publishers (producers) to subscribers (consumers). Publishers communicate asynchronously with subscribers by sending messages to a _topic_, which is a logical access point and communication channel. - SNS supports both Application-to-Application (A2A) and **Application-to-Person (A2P)** messaging, giving flexibility to send messages between different applications or directly to mobile phones, email addresses, and more. ### Common patterns - **Fanout**: when a message is published, it gets replicated to pushed to multiple endpoints (e.g. Firehose delivery, SQS queues, HTTP endpoints, Lambda) ![[sns-fanout 1.png]] - **Application alerts**: alerts that are triggered by predefined threshold. For example user notification or mobile push notifications. >[!info] >**Pricing**: you pay based on the number of messages that you publish, the number of notifications that you deliver, and any additional API calls for managing topics and subscriptions. ### Ordering Just like SQS, SNS has **standard** and **FIFO** topics where FIFO ensures strict message ordering, grouping and deduplication. ### Archive Message archive can be achieved with connecting SNS to Firehose, S3 or Redshidft. Additionally, **SNS FIFO topics support message archiving** and replay as a no-code, in-place message archive that lets topic owners store (or _archive_) messages within their topic. Topic subscribers can then retrieve (or _replay_) the archived messages back to a subscribed endpoint. For more, see [Amazon SNS message archiving and replay for FIFO topics](https://docs.aws.amazon.com/sns/latest/dg/fifo-message-archiving-replay.html). ### Filtering To receive a subset of the messages, a **subscriber must assign a filter policy** to the topic subscription. The `FilterPolicyScope` subscription attribute allows you define the filtering scope by setting one of the following values: - `MessageAttributes` – Applies the filter policy to message attributes (default setting). - `MessageBody` – Applies the filter policy to the message body. ### Raw Message Delivery - By default, SNS wraps published messages in a JSON object that includes metadata about the message and topic. - For subscribers like SQS queues or HTTP/S endpoints that need to receive the exact message as it was published (without the SNS JSON wrapper), you can enable **raw message delivery**. This simplifies message processing for some subscribers.