An SNS topic provides high-throughput, push-based, many-to-many messaging. It's a managed service that allows you to send messages to a large number of subscribers, including distributed systems, microservices, and serverless applications. You can use SNS for both application-to-application (A2A) and application-to-person (A2P) communication.
Under the hood, Stacktape uses Amazon Simple Notification Service (SNS).
When to use them
Stacktape offers three managed resources for messaging and communication:
- SNS topics
- SQS queues
- Event buses
Use an SNS topic when:
- You need to publish messages to many different subscribers with a single action.
- You require high throughput and reliability.
Use an SQS queue when:
- You need reliable, one-to-one, asynchronous communication to decouple your applications.
- You want to control the rate at which messages are consumed.
Use an event bus when:
- You want to publish messages to many subscribers and use the event data itself to filter which messages are delivered to which subscribers.
- You need to integrate with third-party SaaS providers like Shopify, Datadog, or PagerDuty.
Basic usage
You don't need to specify any properties to create a basic SNS topic.
SnsTopicAPI referencetypeRequired
Type: string "sns-topic"
properties.smsDisplayName
Sender name shown on SMS messages sent to subscribers (e.g., "MyApp"). Max 11 characters.
Type: string
properties.fifoEnabled
Guarantees message order and exactly-once delivery. Use for financial transactions, sequential workflows.
Type: boolean
FIFO topics can only deliver to FIFO SQS queues (not email, SMS, or HTTP).
Requires either contentBasedDeduplication: true or a unique MessageDeduplicationId per message.
properties.contentBasedDeduplication
Automatically deduplicates messages based on content (SHA-256 hash) within a 5-minute window.
Type: boolean
Saves you from generating a unique deduplication ID for each message. Requires fifoEnabled: true.
overrides
Escape hatch to modify the underlying CloudFormation resources Stacktape creates.
Type: Object
Use dot-notation paths to override specific properties on any child resource.
Find resource logical IDs with stacktape stack-info --detailed.
overrides:
MyDbInstance:
Properties.StorageEncrypted: true
Integrating with workloads
You can trigger a function or a batch job whenever a message is published to an SNS topic.
A Lambda function with an SNS topic integration.
Publishing messages
You can use the AWS SDK to publish messages to a topic.
FIFO
You can enable FIFO (First-In, First-Out) to ensure that messages are processed in the exact order that they are sent.
FIFO topics can only deliver to FIFO SQS queues (not email, SMS, or HTTP).
Requires either contentBasedDeduplication: true or a unique MessageDeduplicationId per message.
Content-based deduplication
You can enable content-based deduplication to prevent duplicate messages from being sent.
Saves you from generating a unique deduplication ID for each message. Requires fifoEnabled: true.