Amazon EventBridge is a serverless event bus. Services and apps send events to it, and rules decide which events go to which target. It lets you react to things that happen in your account without writing polling code.
What it does
- Receives events, which are small JSON messages that say something happened.
- Uses rules to match events and send them to a target.
- Can also run a rule on a schedule, like a cron job.
- Is fully managed, so there is no server to run.
Key concepts
| Piece | What it is |
|---|---|
| Event | A JSON message that describes a change, such as an instance stopping |
| Event bus | The place where events arrive; the default bus receives AWS service events |
| Rule | A pattern that matches events and picks the targets |
| Event pattern | The filter a rule uses to match an event |
| Target | What receives a matched event, such as Lambda, SQS, SNS or Step Functions |
| Schedule | A rule that fires at a set time or rate instead of on an event |
| Dead-letter queue | An SQS queue for events a target could not take |
Good to know
- Many AWS services send events to the default event bus automatically.
- A rule matches events by their content, so you can react to one kind of change only.
- One rule can have several targets.
- Give the target the right permissions, or the event is matched but nothing happens.
- Add a dead-letter queue to a target so failed deliveries are not lost.
- Scheduled rules are a simple way to run a task every day or every hour.
- Check the current limits, quotas and pricing in the documentation.
Hands-on: try it in your own account
- Open Amazon SNS and create a topic called
practice-topic, then subscribe your email and confirm it. - Open Amazon EventBridge > Rules > Create rule and name it
practice-rule. - Keep the default event bus and choose Rule with an event pattern.
- Pick AWS services, choose EC2 and the event type EC2 Instance State-change Notification, and choose the stopped state.
- Set the target to your
practice-topicSNS topic and create the rule. - Stop a small test EC2 instance and check your email for the event.
- Optional: create a second rule with a schedule that sends a message every hour.
- Clean up: delete both rules, the SNS topic and the test instance.
Common mistakes
- Writing an event pattern that is too wide, so the target fires too often.
- Forgetting the target permissions, so the rule matches but nothing runs.
- Having no dead-letter queue, so failed events are lost.
- Looking at the wrong Region, because rules only see events in their own Region.
- Forgetting to delete practice rules and the test instance.
Key takeaways
- EventBridge routes events from AWS services and your apps to targets.
- A rule matches events by pattern, or fires on a schedule.
- Check the target permissions and add a dead-letter queue.
- Delete the practice rules and resources when you are done.
Tomorrow I'll start a new AWS topic.
Part of #120DaysOfAWS.
