Amazon EventBridge
Amazon EventBridge is a serverless event bus that connects applications using events. It enables event-driven architectures by routing events between AWS services, SaaS applications, and your own applications.
Key Concepts
- Events: JSON objects describing state changes
- Event Bus: A router that receives events and applies rules
- Rules: Define which events to capture and where to send them
- Targets: Destinations for events (Lambda, SQS, SNS, Step Functions, etc.)
Event Sources
- AWS Services: Over 90 AWS services emit events (S3, EC2, CodePipeline, etc.)
- SaaS Partners: Zendesk, Datadog, Auth0, and others
- Custom Applications: Send your own events via the API
Example Event
{
"source": "myapp.orders",
"detail-type": "Order Placed",
"detail": {
"orderId": "12345",
"customerId": "67890",
"amount": 99.99
}
}
Common Patterns
Scheduled Events
Run Lambda functions on a schedule (like cron):
rate(5 minutes)
cron(0 12 * * ? *)
Cross-Account Events
Send events between AWS accounts for decoupled architectures.
Event Archive and Replay
Store events and replay them for debugging or reprocessing.
What We Like
- Decoupling: Producers and consumers don't need to know about each other
- Native integrations: First-class support for AWS services
- Schema registry: Automatic schema discovery and versioning
- Reliability: Built-in retry logic and dead-letter queues
What We Don't Like
- Debugging complexity: Tracing events through multiple services can be challenging
- Eventual consistency: Not suitable for synchronous request/response patterns
- Rule limits: Complex routing logic can hit rule limits
EventBridge vs SNS vs SQS
| Service | Pattern | Use When |
|---|---|---|
| EventBridge | Event routing | Content-based routing, multiple consumers |
| SNS | Pub/Sub | Simple fan-out to multiple subscribers |
| SQS | Queue | Decoupling with guaranteed delivery |