Sub topic 3
Event buses: default, custom, and partner
An event bus is the pipe that receives events and holds the rules that route them. Every event sent to EventBridge goes to exactly one bus, and only the rules on that bus can match it. This chapter covers the three kinds of bus, how to create and address them, and the settings and limits that affect your design.
This chapter assumes you know the basics of AWS accounts, regions, the AWS CLI, JSON, and IAM roles and policies. It also assumes you have seen the structure of an EventBridge event, which the previous chapter covered.
What a bus does
A bus is a regional resource that does three things:
- It accepts events from producers, either through the PutEvents API or from AWS services that publish to it automatically.
- It evaluates each event against every rule attached to that bus.
- It delivers a copy of the event to every target of every rule that matches.
Rules do not span buses. A rule on orders-bus never sees events sent to the default bus. This isolation is the main reason to have more than one bus.
The default event bus
Every account in every region already has a bus named default. You cannot delete it.
AWS services publish their events here. Examples are EC2 state changes, S3 object events (when enabled), CodePipeline state changes, and CloudTrail-based API call events. These events have a source that begins with aws., such as aws.ec2.
You can also send your own events to the default bus. For small systems this works fine. It becomes harder to manage as the system grows, because your application events share one namespace and one set of permissions with AWS service events.
Use the default bus when:
- You react to AWS service events, such as an instance entering the
stoppedstate. - You have a small number of custom events and no need for separate access control.
Custom event buses
A custom bus is one you create for your own applications. It starts with no rules and no permissions for other accounts.
aws events create-event-bus --name orders-busThe command returns the bus ARN, which looks like arn:aws:events:us-east-1:123456789012:event-bus/orders-bus. You need this ARN for cross-account delivery and for IAM policies.
To publish to the bus, set EventBusName in each entry:
aws events put-events --entries '[{"Source":"com.example.orders","DetailType":"OrderPlaced","Detail":"{\"orderId\":\"1001\",\"amount\":250,\"status\":\"new\"}","EventBusName":"orders-bus"}]'If you leave out EventBusName, the event goes to the default bus. This is a common mistake: the call succeeds, but your rules on the custom bus never fire. When a rule does not trigger, check first that the event went to the bus the rule lives on.
Why create custom buses
Custom buses give you boundaries. Each bus has its own:
- Rules. A team can add and change rules without touching other teams' routing.
- Resource-based policy. You decide which principals or accounts may put events on the bus.
- Archives and replays. You archive one domain's events without capturing everything.
- Schema discovery setting. You can turn discovery on for one bus and leave it off for others.
- Monitoring dimensions. CloudWatch metrics are reported per rule, so a bus with a clear purpose is easier to reason about.
Common ways to divide buses are by domain (orders-bus, billing-bus), by environment (orders-bus-dev, orders-bus-prod), or by trust boundary (a bus that accepts events from other accounts, separate from one that does not).
Creating a bus with options
create-event-bus accepts a few optional settings. Some of the more useful ones are a dead-letter queue for the bus itself, a KMS key for encryption, and tags. Check aws events create-event-bus help for the options available in your CLI version, because EventBridge adds bus-level settings over time.
aws events create-event-bus \
--name orders-bus \
--tags Key=team,Value=orders Key=env,Value=prodTags help with cost allocation and with IAM conditions on bus management.
Partner event buses
SaaS providers that are EventBridge partners can send events from their product straight into your account. Examples include monitoring, support, and payments tools. A partner bus is how those events arrive.
The setup has these steps:
- In the EventBridge console, open Partner event sources and find the partner.
- Follow the partner's flow to create an event source in your account. The source has a name that includes the partner's identifier and your configuration.
- The source appears in your account with the status Pending.
- You associate the source with a new partner event bus. The bus takes the name of the source, and its status changes to Active.
- You create rules on that bus the same way you do on any other bus.
The partner event source can only deliver to the account it was created for. You do not create a partner bus with create-event-bus. You create it by accepting the partner source, either in the console or with the CreateEventBus API using the source name as the bus name.
Partner events use a source that starts with aws.partner/, followed by the partner's identifier. Write your event patterns against that source value.
{
"source": [{ "prefix": "aws.partner/example.com" }],
"detail-type": ["Ticket Created"]
}The partner name above is made up. The real prefix is shown on the partner event source in your account.
Behavior to know
- If you delete a partner bus, events from the partner are no longer accepted until you create the bus again.
- A partner bus is visible in the partner's account only as an event source. The partner cannot read your rules or targets.
- Partner events are not sent to your default bus.
Comparing the three
| Feature | Default bus | Custom bus | Partner bus |
|---|---|---|---|
| Created by | AWS, in every account and region | You | You, by accepting a partner event source |
| Can be deleted | No | Yes | Yes |
| Typical publishers | AWS services, and your code if you choose | Your applications | A SaaS partner |
| Event `source` values | `aws.*`, or your own | Your own, such as `com.example.orders` | `aws.partner/...` |
| Cross-account access | Controlled by its resource policy | Controlled by its resource policy | Not applicable for publishing |
| Rules and targets | Yes | Yes | Yes |
Bus resource policies
Each bus can have a resource-based policy. It answers the question: who may send events to this bus? By default, only principals in your own account can call PutEvents on it, subject to their IAM permissions.
To let another account put events on your custom bus, attach a policy to the bus:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPartnerAccountPutEvents",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111122223333:root" },
"Action": "events:PutEvents",
"Resource": "arn:aws:events:us-east-1:123456789012:event-bus/orders-bus"
}
]
}Apply it with aws events put-permission --event-bus-name orders-bus --policy file://policy.json. The next chapters on permissions and cross-account routing cover the sender's side of this arrangement.
Limits and quotas
Buses have account-level quotas. Check the current values in the Service Quotas console, because they change and some can be raised. These are the ones that shape design:
- Number of custom buses per account per region. Large, so a bus per domain is practical, but there is a ceiling.
- Rules per bus. Each bus has its own rule quota, so spreading rules across buses can help with a crowded bus.
- PutEvents throughput. The request rate is limited per region. Batch entries in one call when you can. A single call accepts up to 10 entries, and the total size of the entries is capped.
- Event size. An event, including its envelope, has a maximum size of 256 KB. Put large payloads in S3 and send a reference in the event.
Choosing a bus
Use these questions in order:
- Is the event from an AWS service? It arrives on the default bus. Put your rules there.
- Is the event from a SaaS partner? Accept the partner source and use the partner bus.
- Is the event from your own application? Prefer a custom bus, unless the system is small and a shared namespace is acceptable.
- Do different teams need different permissions, archives, or lifecycles? Use separate custom buses.
Exercises
Exercise
You publish an OrderPlaced event with PutEvents and the call returns FailedEntryCount 0, but the rule you created on orders-bus never triggers. The entry does not include EventBusName. What is the most likely cause, and how do you fix it?
Show answer
Without EventBusName, the event is delivered to the default bus, not to orders-bus. The rule on orders-bus never sees it. Add "EventBusName": "orders-bus" to the entry, or create the rule on the default bus if that is what you intended.
Exercise
A SaaS partner event source shows as Pending in your account. What must you do before you can write rules for its events, and what will the source field of those events start with?
Show answer
Associate the event source with a partner event bus, which changes its status to Active. Then create rules on that bus. The events' source starts with aws.partner/.
Exercise
Give two reasons to use separate custom buses for the orders and billing teams instead of putting everything on the default bus.
Show answer
Each bus has its own rules, so the teams can change routing independently. Each bus also has its own resource policy, so access can be controlled per team. Archives, schema discovery, and metrics can also be scoped per bus.