Sub topic 2
Anatomy of an EventBridge event
This chapter assumes you know JSON, the AWS CLI, and basic IAM. It covers the fields of an EventBridge event, which fields you set and which EventBridge sets, and the errors people hit most often.
The envelope and the detail
Every event is a JSON object with two parts. The envelope is a fixed set of top-level fields. The detail field holds your own payload and can have any JSON structure. Rules match against both parts, and input transformers read from both.
Here is an event as a rule target receives it:
{
"version": "0",
"id": "6a7e8feb-b491-4cf7-a9f1-bf3703467718",
"detail-type": "OrderPlaced",
"source": "com.example.orders",
"account": "123456789012",
"time": "2026-11-26T18:45:49Z",
"region": "us-east-1",
"resources": [],
"detail": {
"orderId": "1001",
"amount": 250,
"status": "new"
}
}Who sets which field
You supply some fields when you publish. EventBridge fills in the rest.
| Field | Set by | Purpose |
|---|---|---|
| `source` | You | Identifies the producer. Use a reverse-DNS name such as `com.example.orders`. |
| `detail-type` | You | Names the kind of event, such as `OrderPlaced`. |
| `detail` | You | Your payload, as a JSON object. |
| `resources` | You (optional) | ARNs of resources the event concerns. |
| `time` | You or EventBridge | Defaults to the time EventBridge received the event. |
| `id` | EventBridge | Unique ID for the event. |
| `account` | EventBridge | The account that published the event. |
| `region` | EventBridge | The Region where the event was received. |
| `version` | EventBridge | Envelope version. It is currently `"0"`. |
Two naming differences matter when you publish. The API call PutEvents uses DetailType and Detail. The delivered event uses detail-type and detail. Patterns and transformer paths use the delivered names.
Detail is a string when you publish it
In PutEvents, Detail is a string that contains JSON. EventBridge parses it and delivers it as a nested object. If the string is not valid JSON, the entry fails.
import json
entry = {
"Source": "com.example.orders",
"DetailType": "OrderPlaced",
"Detail": json.dumps({"orderId": "1001", "amount": 250}),
}
print(entry["Detail"])Building the string with json.dumps avoids the quoting mistakes that hand-escaped JSON causes in shell commands.
How fields map to matching
The pattern language reads the delivered event, so each field you set decides what a rule can filter on. This diagram shows the path from the producer to a rule.
The account and region fields are useful for filtering in multi-account setups, because the producer cannot forge them. For example, a pattern can accept only events whose account is 123456789012.
Common errors
- Reading the wrong key. A pattern that uses
DetailTypenever matches. Usedetail-type. - Matching on a nested field with the wrong path. Patterns mirror the JSON structure of the event, so
amountunderdetailmust appear inside adetailobject in the pattern. - Large payloads. An event entry can be at most 256 KB. Put big data in S3 and send a reference in
detail. - Assuming
resourcesis filled in. It stays empty unless the producer fills it. - Treating
timeas arrival order. A producer can settime, so do not use it to order events.
Exercise
Exercise
A teammate publishes an event with Source set to aws.orders and a Detail value of {"orderId": 7. Name two problems with this entry.
Show answer
First, the aws. prefix is reserved for AWS services, so a custom event should not use it as a source. Second, the Detail string is not valid JSON, because the closing brace is missing, so EventBridge rejects the entry.
Exercise
Which fields in a delivered event does EventBridge set for you, and why does that make account useful in a pattern?
Show answer
EventBridge sets id, account, region, and version, and it sets time if you leave it out. The producer cannot override account, so a pattern can use it to accept events only from trusted accounts.