I needed changes in one product (users unsubscribing from saved searches) to reach a service that lived in another AWS account. Polling an API across accounts would work, but it couples the two teams’ uptime and deploys. EventBridge lets one side announce “this happened” and the other side react, without either knowing much about the other.
The shape
Account A (producer) Account B (consumer)
app ──PutEvents──▶ bus A ──rule──▶ bus B ──rule──▶ Lambda
Three pieces make it work:
- A rule in account A that matches the event and targets the event bus ARN in account B. Give the rule an IAM role that allows
events:PutEventson that bus. - A resource policy on bus B that lets account A put events.
- A rule in account B that routes the event to the Lambda handler.
The policy on bus B looks like this:
{
"Sid": "AllowAccountA",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111111111111:root" },
"Action": "events:PutEvents",
"Resource": "arn:aws:events:us-east-1:222222222222:event-bus/consumer-bus"
}
Treat the event as a contract
The event’s source, detail-type and detail fields are a public API between two teams. I keep them:
- Small: IDs and the fact that something changed, not a full copy of the record.
- Versioned: a
versionfield indetail, so the schema can grow without breaking consumers. - Documented next to the producer’s code, with an example payload.
Reliability details
EventBridge delivers at least once, so the handler must be idempotent. Processing the same unsubscribe twice should be harmless. Beyond that:
- Configure a dead-letter queue on the rule target, and alert when it isn’t empty.
- Set a sensible retry policy (maximum age, attempts) instead of relying on defaults.
- Log the event
idin every handler log line, so you can trace one event across both accounts.
Testing it
Unit-test the handler with recorded sample events. Then add one end-to-end check in a non-production environment: put a test event in account A and assert that the side effect shows up in account B. That single test catches most permission and pattern mistakes, and those are where cross-account setups usually break.