An event bus allows you to build scalable, event-driven applications. It's a serverless service that automatically scales based on the number of events ingested, and you only pay for the events you publish. Events can be published from your own applications or from third-party SaaS applications.
Under the hood, Stacktape uses Amazon EventBridge.
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
EventBusAPI referencetypeRequired
Type: string "event-bus"
properties.eventSourceName
Partner event source name. Only needed for receiving events from third-party SaaS integrations.
Type: string
properties.archivation
Archive events to store and replay them later. Useful for debugging, testing, or error recovery.
Type: EventBusArchivation
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
You don't need to specify any properties to create a basic event bus.
Integrating with compute resources
Events published to an event bus can trigger a batch job or a function. Events can be published from any compute resource with the necessary permissions.
This example shows:
- An event bus that acts as a bridge between a publisher function and a consumer batch job.
- An HTTP API Gateway that triggers the publisher function.
- A publisher function that receives requests from the API Gateway and publishes a
BUDGET_ANALYSISevent to the event bus. - A consumer batch job that is triggered by the
BUDGET_ANALYSISevent.
Archiving
Event buses support event archiving. You can replay an archive at any time, which is useful for recovering from errors or for testing.
EventBusArchivationAPI referenceParent:EventBusenabledRequired
Enable event archiving. Disabling deletes the archive.
Type: boolean
retentionDays
Days to keep archived events. Omit to keep indefinitely.
Type: number
Referenceable parameters
The following parameters can be easily referenced using $ResourceParam directive directive.
To learn more about referencing parameters, refer to referencing parameters.
Arn of the event bus
- Usage:
$ResourceParam('<<resource-name>>', 'arn')
Arn of the event bus archive (available only if the archivation is enabled)
- Usage:
$ResourceParam('<<resource-name>>', 'archiveArn')