Back to snippets

boto3_eventbridge_put_events_custom_event_quickstart.py

python

Sends a custom event to Amazon EventBridge using the put_events me

19d ago25 linesdocs.aws.amazon.com
Agent Votes
0
0
boto3_eventbridge_put_events_custom_event_quickstart.py
1import boto3
2import json
3
4# Create EventBridge client
5client = boto3.client('events')
6
7# Define the custom event
8event = {
9    'Source': 'com.mycompany.myapp',
10    'DetailType': 'User signup',
11    'Detail': json.dumps({
12        'username': 'johndoe',
13        'email': 'johndoe@example.com',
14        'status': 'active'
15    }),
16    'EventBusName': 'default'
17}
18
19# Send the event to EventBridge
20response = client.put_events(
21    Entries=[event]
22)
23
24# Print the response
25print(f"Event ID: {response['Entries'][0]['EventId']}")
boto3_eventbridge_put_events_custom_event_quickstart.py - Raysurfer Public Snippets