Amazon EventBridge: Event Bus and Rules
Amazon EventBridge (formerly CloudWatch Events) is a serverless event bus that makes it easy to connect applications using data from your own applications, integrated SaaS applications, and AWS services. It is the backbone of modern Event-Driven Architectures (EDA).
The Real-World Analogy
Imagine a Central Post Office. Thousands of packages (events) arrive from different senders (AWS Services, SaaS apps). The Post Office doesn’t open the packages; it looks at the label (metadata/pattern). Based on specific sorting rules, it routes the package to the correct delivery truck (Target) like Lambda, SQS, or an external API. If no rule matches, the package is discarded or sent to a Dead Letter Queue (DLQ).
Core Concepts for SAA-C03
1. Event Buses
- Default Event Bus: Receives events from AWS services (e.g., EC2 state changes, S3 via CloudTrail).
- Custom Event Bus: Created for your own applications to send custom events.
- SaaS Event Bus: Receives events from third-party partners like Zendesk, Datadog, or PagerDuty.
2. Rules and Filtering
Rules evaluate incoming events. If an event matches a JSON Event Pattern defined in a rule, EventBridge routes it to the specified target. A single rule can route to up to 5 targets simultaneously.
3. Targets
Common targets include AWS Lambda, Amazon SNS, Amazon SQS, Step Functions, and even API Destinations (which allow you to send events to any HTTP endpoint outside of AWS).
Comparison: EventBridge vs. SNS vs. SQS
| Feature | EventBridge | SNS (Simple Notification Service) | SQS (Simple Queue Service) |
|---|---|---|---|
| Primary Pattern | Event-Driven (Many-to-Many) | Pub/Sub (One-to-Many) | Point-to-Point (Decoupling) | Filtering | Advanced JSON Pattern Matching | Attribute-based only | None (Consumer filters) |
| SaaS Integration | Native Integration | No | No |
| Latency | ~500ms (Higher than SNS) | Sub-100ms | Sub-100ms |
Exam Tips and Gotchas
- The “SaaS” Keyword: If the exam mentions integrating third-party apps like Shopify or PagerDuty, Amazon EventBridge is almost always the correct answer.
- Schema Registry: EventBridge can “discover” the structure (schema) of events automatically. This helps developers generate code bindings.
- Archive & Replay: You can record events and “replay” them later. This is vital for debugging or recovering from downstream failures.
- Cross-Account/Region: EventBridge supports routing events to a bus in a different AWS account or a different region.
- API Destinations: Use this when you need to trigger a 3rd party web-hook directly without a Lambda function intermediary.
Decision Matrix: If-Then Guide
- IF you need to trigger a process based on an EC2 instance state change… THEN use EventBridge (Default Bus).
- IF you need to fan-out a message to 10,000+ subscribers with ultra-low latency… THEN use SNS.
- IF you need to route events based on the content of the message body… THEN use EventBridge.
- IF you need to retry failed events for up to 24 hours… THEN use EventBridge (default retry policy).
Topics covered:
Summary of key subtopics covered in this guide:
- Default vs Custom vs SaaS Event Buses
- Event Pattern Matching and JSON Filtering
- Targets (Lambda, SQS, API Destinations)
- EventBridge Archive and Replay
- Schema Discovery and Registry
- Cross-account event routing
Architectural Flow: EventBridge Hub
Integration
Native integration with 200+ AWS services. Security is managed via IAM Resource-based policies, allowing external accounts to put events on your bus.
Scaling
Fully serverless. Automatically scales to handle high throughput. Default quotas vary by region, but generally support thousands of events per second.
Optimization
$1.00 per million custom events. AWS service events are FREE. Schema Discovery and Archive/Replay have separate minimal costs.
Production Use Case: Order Processing
A customer places an order (Custom Event). EventBridge matches the “OrderPlaced” pattern. It simultaneously:
- Triggers Lambda to process payment.
- Sends data to SQS for the shipping department.
- Invokes an API Destination to update a 3rd party CRM like Salesforce.