← Week 1: Messaging: SQS, SNS, EventBridge

Day 4: EventBridge — Rules, Patterns, and Targets

Phase 5 · Aug 15, 2026

← Week 1: Messaging: SQS, SNS, EventBridge

Agenda (2–3 hours)

  • Read (45 min): AWS EventBridge Developer Guide: event buses, rules, patterns, targets, event replay
  • Study (45 min): Compare EventBridge vs SNS vs SQS: when does each service fit?
  • Practice (45 min): Create a custom event bus; define three rules with pattern matching; route events to Lambda, SQS, and Step Functions targets
  • Challenge (30 min): EventBridge supports 20+ AWS service event sources. Design an architecture that triggers a saga when an EC2 instance changes state
← Week 1: Messaging: SQS, SNS, EventBridge

EventBridge vs SNS vs SQS

Service Fan-out Filtering Sources Replay Schema
SQS No No Producer push DLQ only No
SNS Yes Attribute filter Producer push No No
EventBridge Yes Content filter AWS services, custom Yes (archives) Yes (registry)

Use EventBridge when:

  • Routing events from AWS services (EC2, S3, CodePipeline, etc.)
  • Content-based routing (match on nested JSON fields)
  • Event replay required
  • Schema registry and discovery needed
← Week 1: Messaging: SQS, SNS, EventBridge

Event Pattern Matching

EventBridge rules use JSON patterns to match events:

{
  "source": ["com.myapp.orders"],
  "detail-type": ["OrderPlaced"],
  "detail": {
    "status": ["pending"],
    "amount": [{ "numeric": [">", 1000] }],
    "customer": {
      "tier": ["premium", "enterprise"]
    }
  }
}

Deeply nested content matching without any attribute tagging (unlike SNS). Supports: prefix, exists, anything-but, numeric ranges, IP prefix matching.

← Week 1: Messaging: SQS, SNS, EventBridge

Targets

// Put events to EventBridge
eventbridge.put_events()
    .entries(PutEventsRequestEntry::builder()
        .event_bus_name("my-event-bus")
        .source("com.myapp.orders")
        .detail_type("OrderPlaced")
        .detail(serde_json::to_string(&order)?)
        .build())
    .send()
    .await?;

One rule can have up to 5 targets: SQS, Lambda, Step Functions, SNS, Kinesis, API Gateway, other event buses, etc.

Input transformer: reshape the event before sending to the target:

{ "orderId": "<$.detail.order_id>", "total": "<$.detail.total>" }
← Week 1: Messaging: SQS, SNS, EventBridge

Event Replay

EventBridge archives can replay events from any point in time:

  1. Create an archive: capture all events matching a pattern (or all)
  2. On replay: specify time range → EventBridge re-delivers events to specified targets

Useful for:

  • Rebuilding projections after a bug
  • Re-running a failed downstream integration
  • Testing new event consumers against real historical events
← Week 1: Messaging: SQS, SNS, EventBridge

Key Takeaways

  • EventBridge shines for event routing from AWS services and content-based filtering
  • Patterns match on any JSON field — no attribute tagging required
  • Event replay from archives enables re-processing without a separate event store
  • Schema registry provides discovery and code generation for event types

Tomorrow: message ordering and exactly-once delivery with FIFO queues.