EventBridge is a serverless event bus that routes events from AWS services, SaaS applications, and custom applications to targets. Unlike SNS (pub/sub), EventBridge uses rules for content-based filtering and supports schema registry for event discovery.
Three Types of Event Buses
AWS Services Event Bus (default)
│ All AWS service events (CloudTrail, Config, etc.)
▼
Custom Event Bus
│ Your applications publish here
▼
SaaS Event Bus (Partner Event Bus)
│ Third-party SaaS (Datadog, Shopify, etc.)
▼
# Rule to match specific eventsevents.put_rule( Name='order-shipped-rule', EventBusName='my-event-bus', EventPattern=json.dumps({ 'source': ['com.mycompany.orders'], 'detail-type': ['OrderShipped'], 'detail': { 'status': ['shipped'] } }), State='ENABLED', Targets=[ {'Id': 'lambda-target', 'Arn': 'arn:aws:lambda:us-east-1:123456789012:function:order-processor'}, {'Id': 'sqs-target', 'Arn': 'arn:aws:sqs:us-east-1:123456789012:order-queue'} ])
Schedule Rules (Cron)
# Run Lambda every day at 9 AM UTCevents.put_rule( Name='daily-report-rule', ScheduleExpression='cron(0 9 * * ? *)', State='ENABLED', Targets=[ {'Id': 'lambda-target', 'Arn': 'arn:aws:lambda:us-east-1:123456789012:function:daily-report'} ])
Content Filtering Patterns
// Match orders over $1000{ "detail": { "total": [{"numeric": [">", 1000]}] }}// Match specific status transitions{ "detail": { "status": [{"anything-but": "pending"}], "previous_status": ["pending"] }}// Match with OR{ "detail-type": ["OrderShipped", "OrderDelivered"]}
Schema Registry
# Discover schema from an eventevents.discover_schema( Event='{"source":"com.mycompany.orders","detail-type":"Order","detail":{"order_id":"123"}}')# Bind a schemaevents.create_schema( Name='order-schema', RegistryName='my-registry', Content=json.dumps({ "type": "object", "properties": { "order_id": {"type": "string"}, "total": {"type": "number"} } }), Type='JSONSchemaDraft4')# Use schema in CodePipeline, Lambda (auto-generate typed objects)
Account A (Producer)
│
└── Event Bus A ──► Rule ──► Event Bus B (Account B)
Account B (Consumer)
│
└── Event Bus B (receives from Account A)
│
└── Rules for its own targets
EventBridge rules are evaluated in order — and only the FIRST matching rule’s targets receive the event: Unlike SNS (where ALL subscribers get the message), EventBridge stops after the first matching rule. If you need multiple targets for the same event, use different detail-type values or put all targets in a single rule.
EventBridge schema registry is OPTIONAL — events work without it, but schemas enable code generation: Without schema registry, you parse JSON manually. With it, EventBridge can generate strongly-typed classes for Lambda/CodePipeline.
EventBridge’s detail-type is just a string — there’s no enforcement of format: You can put anything in detail-type. Use a naming convention like com.mycompany.orders.OrderShipped to avoid conflicts.
EventBridge replay replays ALL events from the archive that match the filter — not just failed events: If you archive 100K events and only want to replay the failed ones, you need to filter by event content when replaying or pre-archive selectively.
EventBridge cross-account delivery costs $1/million events — it’s not free: Each event delivered across accounts counts as a custom event. For high-volume cross-account scenarios, consider using EventBridge in the producer account with rules that fan out to SQS queues in each consumer account.