TwiceToldby Develoker
ConceptsSystem designLabsCheat sheetsAbout

Develoker makes free tools for learning to build software. TwiceTold explains each idea twice, as an everyday analogy and the real thing; CloudArch lets you design cloud systems and put load on them.

About ยท Labs ยท Cheat sheets ยท Learning paths

All concepts ยท aws ยท events ยท event-driven ยท serverless ยท messaging

Amazon EventBridge

AWS's serverless event router. Producers put JSON events on an event bus, rules match each event's content against event patterns, and every match is delivered at least once to up to five targets, with retries, dead-letter queues, archive and replay, plus a separate Scheduler for timed invocations.

15 min6 animations

๐Ÿ“š Builds on๐Ÿงบ Amazon SQS and SNS

๐Ÿ–จ๏ธ Cheat sheet

The announcements office

A busy school has notices flying about all day. The football coach has moved Saturday's match. Ms Lee has booked a zoo trip. If everyone had to walk round telling each person who cares, they'd spend all day doing it, and they'd always forget somebody.

So the school has an announcements office, which is called the event bus. Anyone with news writes it on a notice and hands it in. That's all they do. The coach doesn't need to know who cares about the match.

The office keeps a rulebook. Each rule says which notices it's looking for and who gets them: "any notice about sport goes to the PE teacher", "any notice about trips goes to the office tray and to the parents' group". When a notice comes in, the office checks it against every rule, and each rule that fits sends it on.

A notice that fits no rule is simply not sent anywhere. A notice that fits two rules goes to both lists of people. The people handing in notices and the people receiving them never have to meet.

Events, buses, rules and targets

Amazon EventBridge is a serverless event router. Four terms cover most of it:

TermWhat it is
EventA JSON document describing something that happened, such as an order placed or an instance stopped
Event busThe router that receives events; every event is put on exactly one bus
RuleAttached to one bus; an event pattern says which events it matches
TargetWhere a matching event is sent: a Lambda function, SQS queue, SNS topic, Step Functions state machine, another bus, an HTTP API and more

Every event has the same envelope. source and detail-type say who sent it and what kind of event it is, and detail carries the producer's own JSON:

1{2  "version": "0",3  "id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718",4  "detail-type": "Trip booked",5  "source": "com.example.trips",6  "account": "111122223333",7  "time": "2026-06-12T09:30:00Z",8  "region": "eu-west-1",9  "resources": [],10  "detail": { "trip": "zoo", "year": 5, "cost": 12 }11}

The bus evaluates each incoming event against every rule on it. Each matching rule delivers the event to each of its targets, so one event can reach many targets, and an event that matches no rule is discarded. Producers don't know the consumers and consumers don't know the producers, which is the point: you add a consumer by adding a rule, without touching the producer.

Events, a bus, rules and targets5 steps
โšฝFootball coach๐ŸŽ’Ms Lee (trips)๐Ÿ“ขAnnouncements office๐Ÿ“– Sport rule๐Ÿ“– Trip rule๐Ÿง‘โ€๐ŸซPE teacher๐Ÿ“ฅOffice tray๐Ÿ‘ชParents' group
Press play and watch it happen!

Three kinds of office

The school has a main office that gets notices without anyone setting anything up. When the caretaker finds the boiler off or the lights fail, a notice turns up there by itself. This is the default event bus.

Clubs can open their own desk, too. The drama club has a desk just for its own notices ("tickets on sale", "rehearsal moved"), with its own rulebook, so they don't get mixed up with the boiler.

And outside organisations, like the leisure centre down the road, can be given a visitors' desk of their own. When the pool closes, the leisure centre hands its notice in there, and the school's rules decide who hears about it.

Default, custom and partner buses

  • Default event bus: every account has one in each Region. AWS services publish events to it automatically (an EC2 instance changing state, an object created in S3 when EventBridge notifications are enabled on the bucket, a CodePipeline stage failing). Their source starts with aws., such as aws.ec2.
  • Custom event buses: you create these for your own application events, typically one per domain or team. Each has its own rules and its own resource-based policy, which can let other accounts put events on it. Since September 2026 there are two kinds: the new Custom Event Bus, which delivers to subscribers (one target each) and adds ordered delivery per event group, retention of 1 to 365 days and replay, and Custom event bus โ€“ classic, the rules-and-targets model this concept describes.
  • Partner event buses: SaaS partners (support, monitoring and commerce tools, for example) publish to a partner event source in your account, which you associate with a partner bus. From there it's rules and targets as usual.

A rule's target can itself be an event bus in another account or Region, which is how organisations collect events from many accounts into one central bus.

Applications publish with PutEvents, which accepts up to 10 entries per call. Custom events must set source, detail-type and detail. With the AWS SDK for Java 2.x:

1EventBridgeClient events = EventBridgeClient.create();2 3PutEventsResponse response = events.putEvents(PutEventsRequest.builder()4        .entries(PutEventsRequestEntry.builder()5                .eventBusName("drama")6                .source("com.example.drama")7                .detailType("Tickets on sale")8                .detail("{\"show\":\"spring-play\",\"seats\":120}")9                .build())10        .build());11 12if (response.failedEntryCount() > 0) {13    // the call succeeded but some entries didn't: retry the ones whose result has an errorCode14}

PutEvents can partly fail: check failedEntryCount and each entry's result, and retry only the failed entries.

Default, custom and partner buses4 steps
๐ŸงนCaretaker๐ŸŽญDrama club๐ŸŠLeisure centre๐ŸซMain office๐Ÿ“ขDrama club desk๐Ÿ›Ž๏ธVisitors' desk๐Ÿง‘โ€๐Ÿ’ผHead teacher๐Ÿ“ฅTicket tray๐Ÿง‘โ€๐ŸซPE teacher
Press play and watch it happen!

What the rulebook looks at

A rule doesn't just read the heading. It can look at anything written on the notice. "Any notice from the trips teacher about a booked trip" is one rule. "Any booked trip that costs money" is another, and it goes to the payments tray so someone collects the money. That part of the rule, the list of things the notice must say, is called the event pattern.

So when Ms Lee hands in "zoo trip, 12 pounds", both rules fit: the parents' group and the trip planner hear about it, and the payments tray gets it too. When she hands in "museum trip, free", only the first rule fits, so the payments tray stays quiet.

So nobody has to sign up for a whole pile of notices and sort through them. The office reads each notice and picks who gets it, whether it came from the main office, a club's desk or an outside organisation.

Event patterns and content-based routing

An event pattern is JSON with the same shape as the events it matches:

1{2  "source": ["com.example.trips"],3  "detail-type": ["Trip booked"],4  "detail": { "cost": [{ "numeric": [">", 0] }] }5}
  • Every field in the pattern must match (AND); the values listed for a field are alternatives (OR). Fields the pattern doesn't mention are ignored.
  • Plain values match exactly, and string matching is case-sensitive by default. Comparison operators add prefix, suffix, anything-but, numeric ranges, exists, equals-ignore-case, wildcard and $or.
  • A rule can have up to five targets, a limit that can't be raised. Rules per bus have an adjustable default quota (300 in most Regions). Need more targets? Add another rule with the same pattern.
  • An input transformer on a target can reshape the event before delivery, for example to send just detail.trip to an HTTP API.
  • EventBridge needs permission to call each target: a resource-based policy on Lambda, SQS and SNS, or an IAM role for targets such as Step Functions and Kinesis.

Unlike SNS, where a subscriber gets every message on the topic unless it sets a filter policy, EventBridge rules pick events by content from any source. How it compares with the services in SQS and SNS:

EventBridgeSNSSQS
ModelRouter: rules match each event's contentTopic: every subscriber gets every messageQueue: consumers poll and delete
RoutingEvent patterns over any field, including detailOptional filter policy per subscriptionNone; one queue, competing consumers
SourcesAWS services, your apps, SaaS partnersPublishers to the topicProducers to the queue
Holding messagesNot a queue (classic); optional archive for replayStandard topics don't store messages (FIFO topics can archive)Kept until deleted or retention ends
Fan-outUp to 5 targets per rule, many rulesMany subscriptions per topicUse SNS or EventBridge in front

They combine well: a rule that targets an SQS queue gives a consumer a durable buffer it reads at its own pace.

Event patterns route by content4 steps
๐ŸŽ’Ms Lee (trips)๐Ÿ“ขAnnouncements office๐Ÿ“– Rule: any trip๐Ÿ“– Rule: trips that cost๐Ÿ‘ชParents' group๐Ÿ—บ๏ธTrip planner๐Ÿ“ฅPayments tray
Press play and watch it happen!

When nobody answers

The rule for booked trips also says "phone the coach company". One morning their line is busy. The office doesn't give up: it tries again a little later, then later still, waiting a bit longer each time. It keeps trying for up to a whole day.

If the line is still busy at the end, the notice would be thrown away. So the office keeps an undelivered box, which is called a dead-letter queue. The notice goes in there, and the office manager can look at it later and send it again once the coach company is back.

Once in a while the office sends the same notice twice, for example when it isn't sure the first call got through. So everyone who receives notices checks the notice number and ignores one they've already handled.

Delivery, retries and dead-letter queues

EventBridge delivers at least once, and on the default bus and classic buses it doesn't guarantee order. A target can receive the same event more than once, so handlers should be idempotent, for example by recording the event id they have processed.

When a target fails or throttles, EventBridge retries with exponential backoff and jitter. On the default bus and classic buses, the default retry policy keeps trying for up to 24 hours and up to 185 attempts (subscribers on the new Custom Event Bus default to 5 attempts or 300 seconds); set MaximumEventAgeInSeconds and MaximumRetryAttempts per target to shorten it. For API destinations, 401, 407, 409, 429 and 5xx responses are retried; other 4xx responses are not. Errors that retrying can't fix, such as missing permissions or a deleted target, aren't retried: the event goes straight to the DLQ if there is one, otherwise it's dropped.

An event that runs out of retries is dropped, unless the target has a dead-letter queue: a standard SQS queue configured on that target (not on the rule). EventBridge writes the event there with attributes describing the error. Alarm on the queue's depth, fix the cause, then reprocess the messages yourself.

API destinations make any HTTPS endpoint a target. A connection holds the authorisation (basic, API key or OAuth client credentials) and the destination sets an invocation rate limit, so a slow third-party API is called no faster than it can cope with.

Retries and a dead-letter queue5 steps
Undelivered box012๐ŸŽ’Ms Lee (trips)๐Ÿ“ขAnnouncements office๐Ÿ“– Trip rule๐ŸšŒCoach company๐ŸงOffice manager
Press play and watch it happen!

The copy binder

The office can keep a copy binder. Every notice that comes in is also copied into it, and the copies can be kept for a set number of days or for good.

On Monday the trip report helper got the sums wrong. By Wednesday the mistake is fixed, but Monday's notices are long gone. No problem: the office takes Monday's copies from the binder and feeds them through the rulebook again. This is called a replay. The helper gets the notices a second time and gets the sums right.

The office marks replayed notices, so they aren't copied into the binder a second time.

Archive and replay

An archive records events from one bus, all of them or those matching an event pattern, with a retention period in days or indefinitely (the default). A replay sends archived events from a chosen time window back to the same bus they came from, either to all rules or to rules you pick. Replaying doesn't remove anything from the archive, so you can replay the same window more than once.

Replayed events carry a replay-name field, and the managed rule EventBridge creates for the archive ignores events that have it, so replays aren't archived twice. Use replay to recover after a consumer bug, or to backfill a new target. Remember that every matching target receives the replayed events again, so idempotent handlers matter even more here.

๐Ÿ”ง Going deeper

Schema registry: with schema discovery turned on for a bus, EventBridge infers the structure of the events it sees and stores versioned schemas in a registry (AWS service events have their own registry already). From a schema you can generate code bindings, typed classes for Java, Python, TypeScript or Go, so a consumer reads event.getDetail().getCost() instead of picking at raw JSON. The registry is free; discovery is billed per ingested event beyond a free tier.

Archive is not a log you read: you can't point a consumer at an archive and read it like a Kafka topic. Replays go back through the bus and its rules, and they run asynchronously, so a large replay takes time.

Archive and replay4 steps
Copy binder0123๐ŸŽ’Ms Lee (trips)๐Ÿ“ขAnnouncements office๐Ÿ“– Trip rule๐ŸงฎReport helper
Press play and watch it happen!

The timetable bell

Some things don't wait for a notice: they happen on time. Every school day at 8:30 the register helper needs to start the register. On sports day, at 10 o'clock, the sports day planner needs to start the races.

So the school has a timetable bell, called the Scheduler. You give it a time, "every weekday at 8:30" or "just once, on sports day at 10", and say who it calls. When the time comes, the bell calls that person straight away. It knows which part of the world the school is in, so 8:30 stays 8:30 when the clocks change.

A bell set for one day only has done its job afterwards, so it can tidy itself away.

EventBridge Scheduler

EventBridge Scheduler is a separate service (its own scheduler API) for invoking a target on a schedule:

  • at(2026-06-12T10:00:00) for a one-time schedule, rate(5 minutes) or cron(30 8 ? * MON-FRI *) for recurring ones.
  • Each schedule has an IANA time zone (Europe/London), so cron schedules follow daylight saving, plus an optional start and end date.
  • An optional flexible time window lets Scheduler run the invocation any time within, say, 15 minutes, to spread load on the target.
  • One target per schedule: templated targets (Lambda, SQS, SNS, Step Functions, PutEvents to a bus and others) or a universal target that calls almost any AWS API action. Each schedule has its own retry policy and optional DLQ, and runs with an IAM execution role.
  • One-time schedules still count against your quota after they run, unless you set the schedule to be deleted after completion.

The older way is a scheduled rule on the default event bus, which uses the same rate and cron expressions but runs in UTC only and has no one-time schedules. AWS recommends Scheduler for new work. Use a scheduled rule only when one timer needs several targets, or send the schedule to a bus with PutEvents and let rules fan it out.

EventBridge Scheduler4 steps
๐Ÿ—“๏ธ Every weekday 8:30๐Ÿ—“๏ธ Once: sports day 10:00๐Ÿ””Timetable bell๐Ÿ“‹Register helper๐Ÿ…Sports day planner
Press play and watch it happen!

๐Ÿงฉ Quick quiz

Quick quiz! 5 questions about Amazon EventBridge, told the same way as the story.
  1. Ms Lee hands in a notice about a free trip. One rule wants any booked trip, another wants trips that cost money. Who gets it?
  2. The coach company's line stays busy all day. What happens to the notice if the office has an undelivered box for it?
  3. Now and then a helper receives the same notice twice. What should helpers do about it?
  4. The report helper got Monday's sums wrong, and it's now Wednesday. How can the helper see Monday's notices again?
  5. The register must start every school day at 8:30 school time, even after the clocks change. What do you use?
Answer every question to check.Passing marks Amazon EventBridge as done.
Got the hang of Amazon EventBridge? Mark it as done, and your paths show how far youโ€™ve got.

Saved in this browser.

๐Ÿ›ฐ๏ธ AWS in productionStep 4 of 7

โ† Previous on the path๐Ÿš› Amazon ECS, Fargate and EKSNext on the path โ†’๐Ÿƒ AWS Step Functions