Routing Events with Amazon EventBridge
Amazon EventBridge is the central event router of AWS. Services publish events when their state changes, and EventBridge rules match events and deliver them to targets that notify people or take action. This lesson explains event buses, the event structure, event pattern syntax, rules and targets, input transformation, delivery retries and dead-letter queues, archives and replay, cross-account and cross-Region routing, and EventBridge Scheduler and Pipes.
Learning outcomes
After completing this lesson, you will be able to:
- Describe event buses and the structure of an event.
- Write event patterns using exact, prefix, anything-but, numeric, exists and wildcard matching.
- Explain rules, targets, input transformers, retries, dead-letter queues, archives and replay.
- Explain cross-account and cross-Region event routing and the roles of EventBridge Scheduler and Pipes.
Event Buses and Events
An event bus receives events. Every account has a default bus in each Region, which receives events from AWS services. Custom buses receive events from applications through PutEvents and from other accounts, and partner buses receive events from SaaS partners. Events are JSON documents with a standard envelope.
{
"version": "0",
"id": "7bf73129-1428-4cd3-a780-95db273d1602",
"detail-type": "EC2 Instance State-change Notification",
"source": "aws.ec2",
"account": "111122223333",
"time": "2026-11-04T10:15:00Z",
"region": "eu-west-1",
"resources": ["arn:aws:ec2:eu-west-1:111122223333:instance/i-0abcd1234efgh5678"],
"detail": {"instance-id": "i-0abcd1234efgh5678", "state": "stopped"}
}source identifies the producer, detail-type the kind of event, and detail the service-specific content. Rules match on any of these fields.
Event Patterns
A rule's event pattern is a JSON document with the same structure as the events it matches. Each field in the pattern lists the values that match; fields not mentioned are ignored. All fields in the pattern must match (AND), and any value in a list may match (OR). Content filters extend exact matching, as summarised below.
| Filter | Example | Matches |
|---|---|---|
| Exact value list | "state": ["stopped", "terminated"] | Either state |
| Prefix and suffix | "key": [{"prefix": "logs/"}] | Values starting with logs/ |
| Anything-but | "state": [{"anything-but": "running"}] | Any state except running |
| Numeric | "severity": [{"numeric": [">=", 7]}] | Severity 7 or higher |
| Exists | "errorCode": [{"exists": true}] | Events that have an errorCode field |
| Wildcard | "bucket": [{"wildcard": "prod-*-logs"}] | Matching bucket names |
| Equals-ignore-case | "name": [{"equals-ignore-case": "ADMIN"}] | Case-insensitive match |
| $or | "$or": [{"a": [1]}, {"b": [2]}] | Either condition across fields |
{
"source": ["aws.guardduty"],
"detail-type": ["GuardDuty Finding"],
"detail": {
"severity": [{"numeric": [">=", 7]}],
"resource": {"resourceType": ["Instance"]}
}
}The pattern above matches high-severity GuardDuty findings about EC2 instances. Patterns can be tested against sample events in the console or with the TestEventPattern API before they are deployed.
Event pattern rules
Rules, Targets and Input Transformation
A rule on a bus has an event pattern (or a schedule, a legacy option replaced by EventBridge Scheduler) and up to five targets. Targets include Lambda functions, Step Functions state machines, SQS queues, SNS topics, Kinesis streams, Firehose, ECS tasks, CodePipeline pipelines, CodeBuild projects, Systems Manager Automation runbooks and Run Command, Incident and OpsItem creation, API Gateway endpoints, API destinations for external HTTP APIs, CloudWatch log groups and event buses in other accounts or Regions. EventBridge needs permission to invoke each target, through a resource-based policy (Lambda, SNS, SQS) or an IAM role that the rule uses (for example for Step Functions, Kinesis and SSM Automation).
An input transformer extracts values from the event with paths and builds a custom input for the target, for example a readable notification message or exactly the parameters a runbook expects. Alternatively, the target can receive the whole event, a part of it selected with a JSON path, or constant JSON.
"InputTransformer": {
"InputPathsMap": {"instance": "$.detail.instance-id", "state": "$.detail.state", "account": "$.account"},
"InputTemplate": "\"Instance <instance> in account <account> is now <state>.\""
}Delivery, Retries, Archives and Replay
EventBridge delivers events to targets at least once. If a target is unavailable or throttles, EventBridge retries with backoff for up to 24 hours and 185 attempts by default; both limits can be reduced per target. Events that still cannot be delivered are dropped unless the target has a dead-letter queue (an SQS queue), which receives the event with error details. Metrics such as FailedInvocations and InvocationsSentToDlq should be alarmed on. Because delivery is at least once, targets must be idempotent.
An archive stores events from a bus, optionally filtered by pattern, for a retention period or indefinitely. Archived events can be replayed to the bus for a time range, which supports recovery after a target bug, testing new rules against real events, and rebuilding downstream state.
The following diagram shows what happens to an event that cannot be delivered.

EventBridge delivery
Cross-Account and Cross-Region Routing
Operational events from many accounts are often processed centrally. A rule in a source account can target an event bus in another account and Region; the destination bus has a resource-based policy that allows the source accounts, for example by aws:PrincipalOrgID, to put events, and the source rule uses an IAM role that allows events:PutEvents on the destination bus. Rules in the central account then process events from the whole organisation. This is the standard way to centralise GuardDuty, Security Hub, Health and CloudTrail-based alerts, and the source rules are deployed to every account with StackSets.
The following diagram shows events flowing from source accounts to a central bus.

EventBridge Scheduler and Pipes
EventBridge Scheduler invokes targets on schedules, such as cron or rate expressions or one-time schedules, with time zones, flexible time windows, retries and dead-letter queues. It supports millions of schedules and over 200 AWS API targets through universal targets, so it replaces cron jobs on servers and scheduled rules for operational tasks such as nightly clean-ups, reports and start and stop schedules.
EventBridge Pipes connect a single source, such as an SQS queue, a Kinesis or DynamoDB stream or Amazon MQ, to a target with optional filtering, enrichment through Lambda, Step Functions or API calls, and transformation, without writing polling code. Pipes suit point-to-point integrations, while buses and rules suit many-to-many routing.
Rule, Scheduler or Pipe?
Notifying on Failed Pipeline Executions
A platform team wants a chat notification with the pipeline name, stage and execution ID whenever any CodePipeline execution fails in any of 30 accounts, and wants failed notifications to be retried and never lost.
-
Source rules
Deploy a rule with StackSets to every account that matches source aws.codepipeline, detail-type CodePipeline Pipeline Execution State Change and state FAILED, targeting a central bus.
-
Central bus
Allow the organisation to put events on the central bus with a resource policy.
-
Notification
A central rule uses an input transformer to build a message and targets an SNS topic connected to the team's chat channel through Amazon Q Developer in chat applications.
-
Reliability
Configure a dead-letter queue on the target with an alarm, and archive the bus for replay.
An EventBridge rule should match EC2 state changes to any state except running. Which pattern filter should be used?
Show answer
anything-but: "state": [{"anything-but": "running"}] inside detail, with source aws.ec2 and the EC2 Instance State-change Notification detail-type.
Exam Tips
Remember for the exam
- Default buses receive AWS service events; custom buses receive application and cross-account events.
- Patterns: lists are OR, fields are AND; content filters include prefix, anything-but, numeric, exists and wildcard.
- Rules have up to five targets; input transformers build custom target input; EventBridge retries for up to 24 hours and 185 attempts, then uses a DLQ if configured.
- Archives and replay recover from target failures; cross-account routing uses a bus resource policy and a rule role with events:PutEvents.
- EventBridge Scheduler replaces cron; Pipes connect a single source to a target with filtering and enrichment.