[{"data":1,"prerenderedAt":54},["ShallowReactive",2],{"snippet-eventbridge-custom-bus-simple-subscriber":3},{"id":4,"title":5,"contributors":6,"description":8,"extension":9,"gitHub":10,"introBox":13,"languages":18,"meta":22,"resources":23,"services":28,"snippets":30,"stem":51,"tags":52,"type":19,"__hash__":53},"snippets\u002Fsnippets\u002Feventbridge-custom-bus-simple-subscriber.json","Subscribe to a Custom Event Bus",[7],"content\u002Fcontributors\u002Fmarco-buss.json","Create the simplest EventBridge custom event bus subscriber, then publish a test event to it.","json",{"template":11},{"repoURL":12},"https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-snippets\u002Ftree\u002Fmain\u002Feventbridge-custom-bus-simple-subscriber",{"headline":14,"text":15},"How it works",[16,17],"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.",[19,20,21],"AWS CLI","TypeScript","YAML",{},{"bullets":24},[25],{"text":26,"link":27},"Subscribing to events on a custom event bus","https:\u002F\u002Fdocs.aws.amazon.com\u002Feventbridge\u002Flatest\u002Fuserguide\u002Feb-custom-bus-subscribers.html",[29],"eventbridge",[31,47],{"title":32,"codeTabs":33},"Create the subscriber",[34,40],{"title":19,"id":19,"description":35,"snippets":36},"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.",[37],{"language":38,"code":39},"bash","BUS_ARN=\"&#60;EVENT_BUS_ARN&#62;\"\nQUEUE_ARN=\"&#60;TARGET_QUEUE_ARN&#62;\"\nROLE_ARN=\"&#60;DELIVERY_ROLE_ARN&#62;\"\n\naws eventsv2 create-subscriber \\\n  --name \"all-events\" \\\n  --event-bus-arn \"$BUS_ARN\" \\\n  --invoke-configuration \"$(cat &#60;&#60;EOF\n{\"TargetArn\":\"$QUEUE_ARN\",\"RoleArn\":\"$ROLE_ARN\"}\nEOF\n)\"\n",{"id":41,"title":41,"description":42,"snippets":43},"AWS SAM","Deploy with `sam deploy --template-file simple-subscriber-sam.yaml --stack-name simple-subscriber-sam --region \u003CEVENT_BUS_REGION> --parameter-overrides EventBusArn=\u003CEVENT_BUS_ARN> TargetArn=\u003CTARGET_QUEUE_ARN> RoleArn=\u003CDELIVERY_ROLE_ARN> --no-confirm-changeset --no-fail-on-empty-changeset`.",[44],{"language":45,"code":46},"css","AWSTemplateFormatVersion: '2010-09-09'\nTransform: AWS::Serverless-2016-10-31\nDescription: Create the simplest subscriber on an EventBridge enhanced custom event bus.\n\nParameters:\n  EventBusArn:\n    Type: String\n    Description: ARN of the enhanced custom event bus to subscribe to.\n  TargetArn:\n    Type: String\n    Description: ARN of the target that receives the events (for example an SQS queue).\n  RoleArn:\n    Type: String\n    Description: ARN of the IAM role EventBridge assumes to invoke the target.\n\nResources:\n  SimpleSubscriber:\n    Type: AWS::EventsV2::Subscriber\n    Properties:\n      Name: !Sub '${AWS::StackName}-all-events'\n      EventBusArn: !Ref EventBusArn\n      InvokeConfiguration:\n        TargetArn: !Ref TargetArn\n        RoleArn: !Ref RoleArn\n\nOutputs:\n  SubscriberArn:\n    Description: ARN of the created subscriber.\n    Value: !GetAtt SimpleSubscriber.SubscriberArn\n",{"title":48,"description":49,"language":38,"code":50},"Publish a test event","Send an event to the bus with put-raw-events and confirm it reaches the target.","BUS_ARN=\"&#60;EVENT_BUS_ARN&#62;\"\n\nDATA_B64=$(printf '{\"detail\":{\"orderId\":\"A-1001\",\"status\":\"PLACED\",\"total\":42}}' | base64)\n\naws eventsv2 put-raw-events \\\n  --event-bus-arn \"$BUS_ARN\" \\\n  --entries \"$(cat &#60;&#60;EOF\n[{\"Data\":\"$DATA_B64\",\"SystemMetadata\":{\"ContentType\":\"application\u002Fjson\"}}]\nEOF\n)\"\n","snippets\u002Feventbridge-custom-bus-simple-subscriber",[],"xQR7gB4gpGY-wBhXPsFg04QjWMBkkS7iQEX-MMoJnDU",1794047670323]