Routing Events with EventBridge Buses, Rules and Targets
This lesson explains how Amazon EventBridge receives events on an event bus and routes them to targets using rules, which match event patterns or run on a schedule.
Learning outcomes
After completing this lesson, you will be able to:
- Describe how an event bus evaluates each event against its rules.
- Explain how event patterns match events and how input transformers reshape them for a target.
- Describe the permissions, retries and dead-letter queues that govern delivery to targets.
- Distinguish EventBridge Scheduler and EventBridge Pipes from rules on a bus.
- Choose between Amazon SNS and EventBridge for distributing events.
Event buses and events
An event bus receives events and evaluates each one against its rules. A rule contains an event pattern, such as "source is com.example.orders and detail.country is DE", and sends matching events to up to five targets, such as Lambda functions, SQS queues, Step Functions state machines or another bus. Producers do not know which consumers exist, which keeps them decoupled.
Every account has a default bus in each Region, which automatically receives events from AWS services, such as an EC2 instance changing state or a CodePipeline execution failing. Applications should send their own events to a custom bus, which separates them from AWS events and can have its own resource policy, for example to accept events from other accounts. A partner bus receives events from supported SaaS providers, such as a payment or support platform, without polling their APIs. Events on any bus can be archived and replayed later, for example after fixing a bug in a consumer. The following table summarises the bus types.
| Bus | Receives |
|---|---|
| Default bus | Events from AWS services |
| Custom bus | Your application's events |
| Partner bus | Events from SaaS providers |
Every event has source, detail-type, account, region and time fields, plus a detail object carrying the payload. Applications send events with PutEvents, up to 10 per call. An event can be up to 1 MB; the limit was 256 KB until January 2026, the figure older exam questions use.
events.put_events(Entries=[{
"EventBusName": "orders-bus",
"Source": "com.example.orders",
"DetailType": "OrderPlaced",
"Detail": json.dumps({"orderId": "9017", "total": 249.99, "country": "DE"}),
}])Rules and event patterns
A rule matches events against a JSON event pattern, which supports prefix, anything-but, numeric and exists matching. Matching events go to up to five targets, optionally reshaped by an input transformer.
Example. Match large orders from Germany or France. Values in a list are ORed; separate fields are ANDed.
{
"source": ["com.example.orders"],
"detail-type": ["OrderPlaced"],
"detail": {
"total": [{"numeric": [">", 100]}],
"country": ["DE", "FR"]
}
}Delivery to targets
EventBridge delivers events to targets subject to permissions, retries and error handling. The following list describes how delivery works.
- Permissions: Lambda, SNS and SQS targets need resource policies; most others need an IAM role.
- Retries: failed deliveries are retried with backoff for up to 24 hours.
- Dead-letter queues: each target can have one for events it never received.
- Archive and replay: store events and re-send them later.
- Schema Registry: generates code bindings for event structures.
Scheduler and Pipes
In addition to event buses, EventBridge provides two features that do not involve rules on a bus.
EventBridge Scheduler invokes a target at a set time. A schedule can run once, for example to send a reminder 24 hours after a sign-up, or repeatedly with a cron or rate expression in a chosen time zone. Each schedule can call a Lambda function, start a Step Functions execution, send to a queue or call almost any AWS API directly, with its own retry policy and dead-letter queue. Because it supports millions of schedules, an application can create one schedule per user or per order, which scheduled rules on an event bus are not designed for.
EventBridge Pipes connects one source to one target without a Lambda function in between. The source can be an SQS queue, a Kinesis or DynamoDB stream, or a Kafka topic. The pipe reads records from it, can drop records with a filter, can enrich them by calling a Lambda function, a Step Functions workflow or an API, and delivers the result to the target. Pipes replace glue code that only moves and reshapes data. The following table summarises the two features.
| Feature | Use it to |
|---|---|
| EventBridge Scheduler | Run one-time or recurring invocations at scale; the modern way to schedule tasks |
| EventBridge Pipes | Connect one source, such as an SQS queue or DynamoDB stream, to a target, with optional filtering and enrichment and no glue code |
SNS or EventBridge?
SNS and EventBridge both distribute events to multiple targets, but each suits different requirements. The following table identifies the better fit for each requirement and the reason for it.
| Requirement | Better fit | Why |
|---|---|---|
| Fan out an order event to many queues, very high throughput, simple filtering | SNS | Low latency, high throughput fan-out |
| Route events by any field in the payload, from many sources, to many target types | EventBridge | Rich content-based patterns, 20+ target types |
| React to AWS service events such as an EC2 state change | EventBridge | AWS services publish to the default bus |
| Receive events from a SaaS provider such as Zendesk | EventBridge | Partner event sources |
| Replay last week's events after fixing a bug | EventBridge | Archive and replay |
| Send SMS or mobile push notifications | SNS | Direct consumer endpoints |
Both are publish-subscribe services; the choice follows from routing complexity, event sources and the need for features such as archive, replay and schema discovery.
A task must run every day at 06:00 and call a Lambda function. Which EventBridge feature fits?
Show answer
EventBridge Scheduler, with a cron expression and the function as its target. Scheduler also supports one-time schedules and time zones.
Exam Tips
Remember for the exam
- To react to AWS service state changes, such as an EC2 state change or a failed pipeline, use an EventBridge rule.
- To run a Lambda function every hour, use EventBridge Scheduler or a scheduled rule.
- To send custom application events, call
PutEventson a custom event bus. - To capture events a target could not receive, give the target a dead-letter queue.