Subscribe to a Custom Event Bus

Create the simplest EventBridge custom event bus subscriber, then publish a test event to it.

A subscriber on an Amazon EventBridge custom event bus delivers events to a single target. This snippet creates the simplest one: with no filter it receives every event on the bus and delivers the payload unchanged, then publishes a test event to it.
A successful publish only means the bus stored the event, so confirm delivery at the target queue. To filter events, add retries and a dead-letter queue, or transform the payload, see the eventbridge-custom-bus-advanced-subscriber snippet.

Select language:

AWS CLI

Replace the placeholders with your own ARNs. With no filter, this subscriber receives every event on the bus and delivers the raw payload to the target.

BUS_ARN="<EVENT_BUS_ARN>"
QUEUE_ARN="<TARGET_QUEUE_ARN>"
ROLE_ARN="<DELIVERY_ROLE_ARN>"

aws eventsv2 create-subscriber \
  --name "all-events" \
  --event-bus-arn "$BUS_ARN" \
  --invoke-configuration "$(cat <<EOF
{"TargetArn":"$QUEUE_ARN","RoleArn":"$ROLE_ARN"}
EOF
)"

                                                      



Publish a test event

Send an event to the bus with put-raw-events and confirm it reaches the target.

BUS_ARN="<EVENT_BUS_ARN>"

DATA_B64=$(printf '{"detail":{"orderId":"A-1001","status":"PLACED","total":42}}' | base64)

aws eventsv2 put-raw-events \
  --event-bus-arn "$BUS_ARN" \
  --entries "$(cat <<EOF
[{"Data":"$DATA_B64","SystemMetadata":{"ContentType":"application/json"}}]
EOF
)"

                                


Created by:

Marco Buss

Marco Buss

Sr. Solutions Architect at AWS

Follow on LinkedIn