Amazon EventBridge
EventBridge schedules and event rules, the default, partner and custom event buses, archive and replay, the schema registry, cross-account resource policies, and catching API calls through CloudTrail.
What it is
Amazon EventBridge (formerly CloudWatch Events) is a serverless event router. Things happen in AWS and in the customer's applications ("an instance stopped", "a file was uploaded", "an order was placed"); EventBridge receives those events and sends them to the services that should react.
Two basic uses:
- Schedules: cron jobs (scheduled scripts), for example run a Lambda function every hour.
- Event patterns: rules that react to a service doing something, for example when the root user signs in, send a message to an SNS topic that emails the security team.
Targets include triggering Lambda functions and sending SQS or SNS messages, among many others.
Rules
- A source produces an event, a small JSON document. Examples: an EC2 instance starts or stops; CodeBuild reports a failed build; S3 has a new object; Trusted Advisor has a new finding; CloudTrail records any API call; or a schedule fires (for example every 4 hours).
- A rule on the event bus matches events with an event pattern (a filter on the event's fields).
- EventBridge sends matching events to the rule's targets (up to five per rule):
- compute: Lambda, AWS Batch, ECS tasks;
- integration: SQS, SNS, Kinesis Data Streams;
- orchestration: Step Functions, CodePipeline, CodeBuild;
- maintenance: Systems Manager, EC2 actions.
For schedules, AWS now recommends EventBridge Scheduler: it handles millions of schedules, one-time or recurring (cron and rate), with time zones and retries, and can call over 270 AWS services directly.
Event buses
- Default event bus: events from AWS services.
- Partner event bus: events from SaaS partners, such as Zendesk, Datadog or Auth0.
- Custom event bus: events from the customer's own applications, sent with the
PutEventsAPI.
Other features:
- Resource-based policies: event buses can be used by other AWS accounts.
- Archive events (all or filtered) sent to a bus, indefinitely or for a set period, and replay archived events, for example after fixing a bug in a consumer.
- Schema registry: EventBridge can analyse the events on a bus and infer their schema. It can then generate code for the application that knows in advance how the event data is structured. Schemas are versioned.
- EventBridge Pipes: point-to-point integrations from one source (such as an SQS queue or a DynamoDB stream) to one target, with optional filtering and enrichment.
Updated since the slides
AWS now offers a new Custom Event Bus that delivers events to subscribers created by consumers, keeps events for a set period, and supports ordered delivery and replay. The rules-and-targets buses described above are now called Custom Event Bus - Classic, and remain available. This change is newer than the exam material; the rules model is what questions use.
Resource-based policies
A resource-based policy manages permissions for a specific event bus: for example, allow or deny events from another AWS account or Region.
Use case: aggregate all events from an AWS Organization into one central account or Region. The central bus's policy allows events:PutEvents from the other accounts (or the whole organization), and each account forwards its events there.
Intercepting API calls
CloudTrail records API calls and sends them to EventBridge as events, so a rule can react to any API call in the account:
- a user calls DynamoDB
DeleteTable→ alert through SNS; - a user calls
AssumeRoleon an IAM role → alert; - a user edits security group inbound rules (
AuthorizeSecurityGroupIngress) → alert.
CloudTrail is covered in the Monitoring & Governance group.
Real-world examples
- A nightly report runs as a Lambda function on an EventBridge schedule at 02:00 UTC.
- A security team gets an SNS alert within seconds whenever someone opens port 22 to the internet, through CloudTrail and an EventBridge rule.
- A support team routes new Zendesk tickets from a partner event bus to a Lambda function that classifies them.
- A company with 40 accounts forwards all GuardDuty findings to a central security account's event bus.
Exam tips
- "Run a function on a schedule", "cron in AWS" → EventBridge schedule (or EventBridge Scheduler).
- "React when an EC2 instance stops", "when an S3 object is created" → EventBridge rule.
- "Alert when someone calls a specific API" → CloudTrail + EventBridge rule + SNS.
- "Receive events from a SaaS application" → partner event bus.
- "Centralize events from all accounts" → event bus resource-based policy (allow the organization).
- "Reprocess past events after a bug fix" → archive and replay.
- "Generate code bindings for event structures" → schema registry.
Common traps
- "Use SNS to react to an EC2 state change." The event comes through EventBridge; SNS can be the target.
- "EventBridge needs a running server for cron jobs." Schedules are serverless.
Hands-on lab: a scheduled rule and an event rule
Goal: send an email whenever an EC2 instance changes state.
Costs money
EventBridge rules on AWS service events are free; SNS email is free for 1,000 messages a month. Starting and stopping a t3.micro for a minute costs under a cent. Any Region works.
Before you start: have an SNS topic with a confirmed email subscription, as in the SNS lab.
Create the rule
EventBridge → Rules → Create rule. Name saa-ec2-state, event bus default, rule type Rule with an event pattern. Event source AWS services → EC2 → EC2 Instance State-change Notification, any state. Target SNS topic → your topic. Create.
Trigger it
Stop (or start) any EC2 instance, such as saa-web. Within a minute you receive an email containing the event JSON, with the instance ID and the new state.
Expected result: an email for every EC2 state change, without writing code.
Clean up: delete the saa-ec2-state rule (and the SNS topic if you no longer need it).