EventBridge Event Patterns and Rules
~10 min read
How EventBridge decides which events go to which targets, based on actual event content.
An EventBridge Rule contains an event pattern — a JSON structure that's matched against incoming events' fields (commonly source, detail-type, and specific fields within the detail payload). Only events whose structure matches the pattern trigger that rule's configured target(s); this content-based matching is far more expressive than SNS's simpler attribute-based filtering, supporting exact matches, prefixes, numeric ranges, and more.
A single event can match multiple rules simultaneously, fanning out to multiple different targets, similar in spirit to SNS's fan-out but driven by content rather than topic subscription — meaning a producer publishes events without needing to know in advance how many or which rules might match them.
EventBridge supports multiple event buses: the default bus (receiving events from AWS services automatically), custom buses (for your own application's events), and partner event buses (receiving events from integrated third-party SaaS platforms) — rules are defined per-bus, letting you organize routing logic by event source domain rather than mixing everything into one undifferentiated stream.
💻 Code example
{
"source": ["myapp.orders"],
"detail-type": ["OrderPlaced"],
"detail": {
"amount": [{"numeric": [">", 1000]}]
}
}
💬 Deep Dive with AI
Key points
- •Event patterns match against source, detail-type, and detail fields — more expressive than SNS filtering
- •One event can match multiple rules, fanning out to multiple targets based on content
- •Default bus (AWS service events), custom buses (your app), and partner buses (third-party SaaS) organize routing by domain
- •Producers don't need to know in advance which rules will match their published events