Reputation: 501
I have a lambda defined in say, account A which is sending events to an EventBridge in say, account B. Below is the code that I use to push data (put_events) using Python boto3 client.
rlogger.info("Trying to send events with boto3 client " + str(json_string))
try:
response = client.put_events(
Entries=[
{
'Time': str(datetime.datetime.utcnow()),
'Source': 'notifications-test',
'DetailType': 'EVENT_SAMPLE',
'Detail': str(json_string),
'EventBusName': str(event_metadata["destination"])
},
]
)
The destination
is an ARN of the event bridge in account B. I get the following client side error when I try to run the lambda.
2022-02-10 18:29:34,391 [MainThread ] [ERROR] Error sending records to event-bridge.An error occurred (ValidationException) when calling the PutEvents operation: Cross-region api call is not allowed.
Can someone help me with this?
Upvotes: 0
Views: 2390
Reputation: 1326
Make sure the region of your eventbridge client is the same as the region of the target event bus
client = boto3.client('events', region_name="<same region as defined in target ARN>")
Upvotes: 2