The town square — EventBridge
In a town square, people pin announcements on a notice board. Anyone interested reads them and acts — the person who posted doesn't need to know who's reading. Amazon EventBridge is that notice board for microservices.
How the notice board works
- A human announces an event to an event bus (
OrderPlacedfromcafe.waiter). - Rules on the bus match events by their content.
- Each rule delivers matching events to targets — another human's queue, a Lambda function, a Step Functions workflow, an API destination and more.
Waiter ──OrderPlaced──► [ TOWN SQUARE bus ]
├─ rule "chef hears new orders" → SQS chef-inbox → Chef
├─ rule "cashier hears new orders" → SQS cashier-inbox → Cashier
└─ rule "archive everything" → Firehose → S3 (history)
Writing rules in CDK
import * as events from "aws-cdk-lib/aws-events";
import * as targets from "aws-cdk-lib/aws-events-targets";
import * as sqs from "aws-cdk-lib/aws-sqs";
// The Chef's inbox, with a place for letters it can't handle
const chefDeadLetters = new sqs.Queue(this, "ChefDeadLetters", { retentionPeriod: Duration.days(14) });
const chefInbox = new sqs.Queue(this, "ChefInbox", {
visibilityTimeout: Duration.seconds(60),
deadLetterQueue: { queue: chefDeadLetters, maxReceiveCount: 3 },
});
// The Chef listens for new orders on the town square
new events.Rule(this, "ChefHearsNewOrders", {
eventBus: townSquare,
eventPattern: { source: ["cafe.waiter"], detailType: ["OrderPlaced"] },
targets: [new targets.SqsQueue(chefInbox)],
});
Rules can also match on the event's content — e.g. only orders above a certain total, or only takeaway orders:
eventPattern: {
source: ["cafe.waiter"],
detailType: ["OrderPlaced"],
detail: { total: [{ numeric: [">=", 1000] }] }, // big orders only
},
Why deliver to a queue instead of straight to a function?
A queue is a personal inbox. It:
- Absorbs bursts — 500 orders in a minute become a steady stream the Chef handles at its own pace.
- Retries failures automatically and moves repeatedly failing letters to a dead-letter queue.
- Decouples availability — if the Chef is being redeployed, letters wait.
The beauty of choreography
Tomorrow the café adds a Loyalty human that gives points for every order. You add one rule and one new human. The Waiter doesn't change at all. That's loose coupling: the society grows without surgery on existing humans.
The risks of choreography
| Risk | Mitigation |
|---|---|
| Nobody can see the whole story | Correlation IDs in every event; tracing; an event archive; documented flows |
| Event schemas drift | Schema registry; versioned, backward-compatible events |
| Loops (A reacts to B reacts to A…) | Clear ownership of events; review new rules |
| Lost events | Queues with DLQs; EventBridge archive and replay |
Useful notice-board features
- Archive and replay — keep events and replay them (e.g. to rebuild a new human's memory or recover after a bug).
- Schema registry — discover and document event shapes.
- Cross-account buses — societies spread across accounts can share a notice board.
- Scheduler — post timed announcements ("every morning at 7, open the café").
- Pipes — connect a source (like a queue or stream) to a target with filtering and enrichment, no glue code.
The town square lets humans cooperate without knowing each other. Announce facts, route them with rules, deliver into inboxes — and new humans can join without anyone else changing.