EventBridge Custom Event Bus
Introduction
Section titled “Introduction”The EventBridge Custom Event Bus is an event bus that retains the events it receives and delivers them to subscribers, each with its own filters, transformer, and target. See What is the EventBridge Custom Event Bus for an overview of the service and how it differs from the classic event bus described on the EventBridge page.
LocalStack lets you use the Custom Event Bus APIs in your local environment to create event buses, subscribers, and event sources, publish events, replay retained events, and share buses across accounts. The supported APIs are available on the API coverage section, which provides information on the extent of the Custom Event Bus integration with LocalStack.
Getting started
Section titled “Getting started”This guide is designed for users new to the Custom Event Bus and assumes basic knowledge of the AWS CLI and our lstk aws command.
Start your LocalStack container using your preferred method. We will demonstrate how to create an event bus, an SQS queue, a delivery role, and a subscriber with a filter, and how to publish events and receive the matching ones.
Create an event bus
Section titled “Create an event bus”Create an event bus with the CreateEventBus API:
lstk aws eventsv2 create-event-bus --name orders-bus{ "EventBusArn": "arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq", "Name": "orders-bus", "StorageConfiguration": { "RetentionPeriodInDays": 1, "RetentionWindowStartTime": "2026-11-04T20:34:48.019616+01:00" }, "State": "CREATING", "CreationTime": "2026-11-04T20:34:48.019616+01:00"}The bus keeps events for one day by default.
Set --storage-configuration RetentionPeriodInDays=<days> to keep them for up to 365 days.
Every bus gets an ARN with a unique id, so a bus that you delete and create again under the same name has a new ARN.
As on AWS, you can create up to 5 event buses per account and region.
The bus moves to the ACTIVE state once it is ready:
lstk aws eventsv2 describe-event-bus \ --event-bus-arn arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq \ --query State"ACTIVE"Create an SQS queue
Section titled “Create an SQS queue”Create the queue that receives the events:
lstk aws sqs create-queue --queue-name orders-queue{ "QueueUrl": "http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/orders-queue"}Create a delivery role
Section titled “Create a delivery role”A subscriber delivers events with a delivery role in its own account, which EventBridge assumes. Create a trust policy that allows EventBridge to assume the role:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "events.amazonaws.com" }, "Action": "sts:AssumeRole" } ]}Create the role and allow it to send messages to the queue:
lstk aws iam create-role \ --role-name orders-delivery-role \ --assume-role-policy-document file://trust-policy.json \ --query Role.Arnlstk aws iam put-role-policy \ --role-name orders-delivery-role \ --policy-name send-to-queue \ --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"sqs:SendMessage","Resource":"arn:aws:sqs:us-east-1:000000000000:orders-queue"}]}'"arn:aws:iam::000000000000:role/orders-delivery-role"Create a subscriber
Section titled “Create a subscriber”Create a filter that matches OrderPlaced events with an amount greater than 100:
{ "Filters": [ { "Scope": "DATA", "Pattern": "{\"detail-type\": [\"OrderPlaced\"], \"detail\": {\"amount\": [{\"numeric\": [\">\", 100]}]}}" } ]}Create a subscriber that delivers the matching events to the queue:
lstk aws eventsv2 create-subscriber \ --name large-orders \ --event-bus-arn arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq \ --invoke-configuration TargetArn=arn:aws:sqs:us-east-1:000000000000:orders-queue,RoleArn=arn:aws:iam::000000000000:role/orders-delivery-role \ --filter-configuration file://filter-configuration.json{ "SubscriberArn": "arn:aws:events:us-east-1:000000000000:subscriber/large-orders/avf41lgwcg1a0yphcqquygj5p", "Name": "large-orders", "EventBusArn": "arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq", "Type": "UNORDERED", "StartingPosition": "LATEST", "State": "RUNNING", "CreationTime": "2026-11-04T20:35:10.276857+01:00"}The subscriber starts at the LATEST position, so it receives the events published after its creation.
Publish events
Section titled “Publish events”Create a file with two orders, one above and one below the amount in the filter:
[ { "Source": "com.example.orders", "DetailType": "OrderPlaced", "Detail": "{\"orderId\": \"1001\", \"amount\": 250}" }, { "Source": "com.example.orders", "DetailType": "OrderPlaced", "Detail": "{\"orderId\": \"1002\", \"amount\": 20}" }]Publish them with the PutEvents API:
lstk aws eventsv2 put-events \ --event-bus-arn arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq \ --entries file://events.json{ "FailedEntryCount": 0, "Entries": [ { "EventId": "42f2b910-fa41-4e3c-88f2-0357603024b2", "SequenceNumber": "10000000000000003000", "SuccessCode": "PUBLISHED" }, { "EventId": "c348603e-1e30-48c6-b862-f60e38417bd4", "SequenceNumber": "10000000000000003001", "SuccessCode": "PUBLISHED" } ]}Every event gets a sequence number on the bus.
As on AWS, the EventId that PutEvents returns is the event’s aws:EventId system metadata, not the id of the delivered event.
Receive the event
Section titled “Receive the event”Receive the messages from the queue:
lstk aws sqs receive-message \ --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/orders-queue \ --max-number-of-messages 10 \ --wait-time-seconds 5{ "Messages": [ { "MessageId": "9d142381-23ee-400e-a6e7-a3e46a2aff4d", "ReceiptHandle": "Yzc2ZDI5N2QtNmE0ZC00YTljLTg1YTUtNDk4MTM5YzA0ZjM1IGFybjphd3M6c3FzOnVzLWVhc3QtMTowMDAwMDAwMDAwMDA6b3JkZXJzLXF1ZXVlIDlkMTQyMzgxLTIzZWUtNDAwZS1hNmU3LWEzZTQ2YTJhZmY0ZCAxNzkzODIwOTE4LjA1MDc2NTg=", "MD5OfBody": "1819980d0076750d69d443f8d4848703", "Body": "{\"version\":\"0\",\"id\":\"1401d847-110a-4fad-9ec9-8e57bbdb5efe\",\"detail-type\":\"OrderPlaced\",\"source\":\"com.example.orders\",\"account\":\"000000000000\",\"time\":\"2026-11-04T19:35:16Z\",\"region\":\"us-east-1\",\"resources\":[],\"detail\":{\"orderId\":\"1001\",\"amount\":250}}" } ]}Only the order with an amount of 250 matches the filter. An SQS target receives one message per event.
Supported features
Section titled “Supported features”LocalStack supports the following Custom Event Bus features. See the linked AWS documentation for how they work.
- Subscribers, unordered or FIFO, with batching.
- Filters on the event data, metadata, and system metadata.
- Transformers (
RAW,WITH_METADATA, andJSONATA), and{% %}JSONata expressions in target parameters. - Retries and dead-letter queues.
- Replay from the oldest retained event or from a point in time, and stopping and resuming subscribers.
- Publishing with
PutEventsandPutRawEvents, with deduplication, and raw events in JSON, binary, or Avro format. - Event sources for AWS service events.
- Delivery logs through CloudWatch Logs vended log delivery.
- Resource policies, sharing buses with other accounts through AWS RAM, and revoking other accounts’ subscribers and event sources with
RevokeResource.
Supported targets
Section titled “Supported targets”LocalStack supports the following subscriber targets:
- SQS standard and FIFO queues.
- Lambda functions, with the
EVENTandREQUEST_RESPONSEinvocation types, qualifiers, and durable functions. - Step Functions state machines, with asynchronous executions and synchronous executions of Express workflows.
- SNS topics.
- Kinesis data streams.
- Firehose streams.
- API Gateway REST APIs.
- API destinations, with basic, API key, and OAuth client credentials connections.
- Another Custom Event Bus.
- A classic EventBridge event bus.
- Universal targets, which call an AWS API action with the event as input.
Avro events
Section titled “Avro events”PutRawEvents decodes Avro events in the AWS Glue wire format, using the Glue Schema Registry that you pass with --schema-registry-configuration.
LocalStack caches the schema versions it looks up for 300 seconds, including failed lookups.
Set EVENTBRIDGEV2_SCHEMA_CACHE_TTL to change the duration, or to 0 to look up the schema for every event.
Event sources
Section titled “Event sources”LocalStack implements an event source as a managed rule on the classic default event bus of your account, which forwards the matching events to the Custom Event Bus unchanged. Any event that a LocalStack service publishes to the default event bus can be forwarded.
Create a bucket and turn on its EventBridge notifications:
lstk aws s3api create-bucket --bucket orders-invoiceslstk aws s3api put-bucket-notification-configuration \ --bucket orders-invoices \ --notification-configuration '{"EventBridgeConfiguration": {}}'Create an event source that forwards the bucket’s Object Created events:
lstk aws eventsv2 create-event-source \ --name invoices-source \ --event-bus-arn arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq \ --configuration '{"AwsServiceEventsConfiguration": {"AwsService": "aws.s3", "Pattern": "{\"detail-type\": [\"Object Created\"], \"detail\": {\"bucket\": {\"name\": [\"orders-invoices\"]}}}"}}'{ "EventSourceArn": "arn:aws:events:us-east-1:000000000000:event-sourcev2/aws.service/invoices-source/5cq6ljbd6m2pox7nf9fs1k5jg", "Name": "invoices-source", "EventBusArn": "arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq", "State": "ACTIVE", "CreationTime": "2026-11-04T20:56:11.221049+01:00"}Upload an object to the bucket:
lstk aws s3 cp invoice-1007.txt s3://orders-invoices/invoice-1007.txtThe subscribers of the bus receive the S3 event, for example the orders-replay subscriber, which has no filter:
lstk aws sqs receive-message \ --queue-url http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/orders-replay-queue \ --max-number-of-messages 10 \ --wait-time-seconds 5 \ --query 'Messages[].Body'[ "{\"version\":\"0\",\"id\":\"c74479fa-8671-4efd-97d6-24dfdf97b7ab\",\"detail-type\":\"Object Created\",\"source\":\"aws.s3\",\"account\":\"000000000000\",\"time\":\"2026-11-04T19:56:11Z\",\"region\":\"us-east-1\",\"resources\":[\"arn:aws:s3:::orders-invoices\"],\"detail\":{\"version\":\"0\",\"event-version\":\"1.2\",\"bucket\":{\"name\":\"orders-invoices\"},\"object\":{\"key\":\"invoice-1007.txt\",\"size\":3,\"etag\":\"764efa883dda1e11db47671c4a3bbd9e\",\"sequencer\":\"006AEB8DDB00000000\"},\"request-id\":\"99255287-4fe4-4898-96ab-6a89c1eb5e4f\",\"requester\":\"000000000000\",\"source-ip-address\":\"127.0.0.1\",\"reason\":\"PutObject\"}}"]Logging
Section titled “Logging”Subscribers deliver their logs to CloudWatch Logs through vended log delivery, with the subscriber as the delivery source.
Turn on logging for the large-orders subscriber, and create a log group:
lstk aws eventsv2 update-subscriber \ --subscriber-arn arn:aws:events:us-east-1:000000000000:subscriber/large-orders/avf41lgwcg1a0yphcqquygj5p \ --log-configuration Level=INFO,IncludePayload=FULLlstk aws logs create-log-group --log-group-name /aws/vendedlogs/large-ordersCreate a delivery source for the subscriber:
lstk aws logs put-delivery-source \ --name large-orders-logs \ --resource-arn arn:aws:events:us-east-1:000000000000:subscriber/large-orders/avf41lgwcg1a0yphcqquygj5p \ --log-type INFO_LOGS{ "deliverySource": { "name": "large-orders-logs", "arn": "arn:aws:logs:us-east-1:000000000000:delivery-source:large-orders-logs", "resourceArns": [ "arn:aws:events:us-east-1:000000000000:subscriber/large-orders/avf41lgwcg1a0yphcqquygj5p" ], "service": "events", "logType": "INFO_LOGS" }}Create a delivery destination for the log group, and connect the two with a delivery:
lstk aws logs put-delivery-destination \ --name large-orders-log-group \ --delivery-destination-configuration destinationResourceArn=arn:aws:logs:us-east-1:000000000000:log-group:/aws/vendedlogs/large-orderslstk aws logs create-delivery \ --delivery-source-name large-orders-logs \ --delivery-destination-arn arn:aws:logs:us-east-1:000000000000:delivery-destination:large-orders-log-groupWhen an event is delivered, the log group receives a SUBSCRIBER_MATCHED record and an EVENT_DELIVERY_ATTEMPT record.
The following command shows the main fields of the delivery attempt:
lstk aws logs filter-log-events \ --log-group-name /aws/vendedlogs/large-orders \ --filter-pattern '{ $.message_type = "EVENT_DELIVERY_ATTEMPT" }' \ --query 'events[0].message' \ --output text | jq '{message_type, event_id, details: (.details | {outcome, attempt_count, target_arn})}'{ "message_type": "EVENT_DELIVERY_ATTEMPT", "event_id": "9e9e2070-7b43-4f24-8ab8-5c765255f0af", "details": { "outcome": "SUCCESS", "attempt_count": 1, "target_arn": "arn:aws:sqs:us-east-1:000000000000:orders-queue" }}Failed attempts, transformation failures, and dead-letter queue writes are logged as well, with their error code and message.
Access control and sharing
Section titled “Access control and sharing”IAM enforcement
Section titled “IAM enforcement”LocalStack enforces the bus resource policies, the delivery role, and identity policies when you start it with IAM enforcement (ENFORCE_IAM=1).
Without IAM enforcement, any account can publish to and subscribe to any bus, while operations reserved for the bus owner, such as UpdateEventBus, still fail from other accounts.
Sharing a bus with AWS RAM
Section titled “Sharing a bus with AWS RAM”You can share a bus with other accounts through AWS RAM, with one of the four AWS managed permissions for event buses.
Share the bus with the account 111111111111:
lstk aws ram create-resource-share \ --name orders-bus-share \ --resource-arns arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq \ --principals 111111111111 \ --permission-arns arn:aws:ram::aws:permission/AWSRAMEventBridgeEventBusV2SubscribeOnly{ "resourceShare": { "resourceShareArn": "arn:aws:ram:us-east-1:000000000000:resource-share/ce58f3ad-7e97-4359-9180-40549d91754b", "name": "orders-bus-share", "owningAccountId": "000000000000", "allowExternalPrincipals": true, "status": "ACTIVE", "tags": [], "creationTime": "2026-11-04T20:54:45.694475+01:00", "lastUpdatedTime": "2026-11-04T20:54:45.694476+01:00", "resourceShareConfiguration": { "retainSharingOnAccountLeaveOrganization": false } }}The shared bus now appears in the consumer account’s list of buses:
lstk aws --account 111111111111 eventsv2 list-event-buses{ "EventBuses": [ { "Name": "orders-bus", "EventBusArn": "arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq", "EventBusAccountId": "000000000000" } ]}The consumer account creates subscribers on the shared bus in its own account, with its own delivery role and target.
The following command assumes that the account 111111111111 has a shipping-queue queue and a shipping-delivery-role role, created as in the getting started guide:
lstk aws --account 111111111111 eventsv2 create-subscriber \ --name shipping \ --event-bus-arn arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq \ --invoke-configuration TargetArn=arn:aws:sqs:us-east-1:111111111111:shipping-queue,RoleArn=arn:aws:iam::111111111111:role/shipping-delivery-role{ "SubscriberArn": "arn:aws:events:us-east-1:111111111111:subscriber/shipping/0tur41je37r6hoy0ky72pzlvp", "Name": "shipping", "EventBusArn": "arn:aws:events:us-east-1:000000000000:event-busv2/orders-bus/umsn1mzdebj8ynyo3i9hphbdq", "Type": "UNORDERED", "StartingPosition": "LATEST", "State": "RUNNING", "CreationTime": "2026-11-04T20:54:57.335582+01:00"}The events that the owner publishes now also reach the consumer’s queue.
Persistence
Section titled “Persistence”With persistence or a snapshot, LocalStack keeps the event buses with their policies and tags, the subscribers, the event sources, the retained events, and each subscriber’s position. After a restart, subscribers continue where they left off: events that were waiting for delivery or a retry are delivered again, with a fresh retry budget. The deduplication window is not kept, so an event published again within 5 minutes after a restart is not treated as a duplicate.
Current Limitations
Section titled “Current Limitations”- LocalStack does not support partner event sources, in the Custom Event Bus or in EventBridge. Creating an event source with a
PartnerEventsConfigurationfails. PutRawEventsdecodes Avro events from a Glue Schema Registry only. Protobuf events and Confluent schema registries are rejected.- With IAM enforcement, LocalStack does not check whether the caller of
PutRawEventsmay read the schema withglue:GetSchemaVersion. A caller without that permission can still publish Avro events. - LocalStack does not emit the Custom Event Bus CloudWatch metrics.
- Subscriber logs are only delivered to CloudWatch Logs log groups in the same account and region. S3, Firehose, and cross-account delivery destinations receive no logs.
- When a bus is shared through AWS RAM, only account principals get access. Organization and organizational unit principals don’t, and the
AWS_RAMpolicy has noaws:PrincipalOrgIDcondition. - LocalStack does not check whether the caller may use the KMS key of an encrypted bus, and it accepts events for a bus whose key is disabled.
- Changes take effect immediately. On AWS, new subscribers, state and filter changes, and shares can take a few seconds to apply, and events published while a point-in-time subscriber starts may be marked as
REPLAY. Tests that pass on LocalStack may need waits on AWS. - LocalStack enforces the quota of 5 event buses per account and region, but not the other Custom Event Bus quotas, such as the number of concurrent replays per bus or one subscriber creation or deletion at a time per bus.
API Coverage
Section titled “API Coverage”24 of 25 operations implemented
Available from the Ultimate plan. Licensing details
Find an API
Search the full operation list, then sort the table to compare current support.
Loading operations…
| Verified on Kubernetes | ||
|---|---|---|
| Loading operations… | ||
Complete static API list All 25 operations and their current support status
| Operation | Status |
|---|---|
| CreateEventBus | Implemented |
| CreateEventSource | Implemented |
| CreateSubscriber | Implemented |
| DeleteEventBus | Implemented |
| DeleteEventSource | Implemented |
| DeleteResourcePolicy | Implemented |
| DeleteSubscriber | Implemented |
| DescribeEventBus | Implemented |
| DescribeEventSource | Implemented |
| DescribeSubscriber | Implemented |
| GetResourcePolicy | Implemented |
| ListEventBuses | Implemented |
| ListEventSources | Implemented |
| ListResourcePolicies | Implemented |
| ListSubscribers | Implemented |
| ListTagsForResource | Implemented |
| PutEvents | Implemented |
| PutRawEvents | Implemented |
| PutResourcePolicy | Implemented |
| RevokeResource | Not implemented |
| TagResource | Implemented |
| UntagResource | Implemented |
| UpdateEventBus | Implemented |
| UpdateEventSource | Implemented |
| UpdateSubscriber | Implemented |