简体   繁体   中英

Invoking lambda with CloudWatch events across regions

I have a lambda function deployed in us-east-1 which runs every time an EC2 instance is started. The lambda function is triggered with the following EventBridge configuration:

{
  "detail-type": [
    "AWS API Call via CloudTrail"
  ],
  "source": [
    "aws.ec2"
  ],
  "detail": {
    "eventName": [
      "RunInstances"
    ]
  }
}

The lambda function is working great. Now, I'm looking to extend this so that my lambda function is triggered even when an EC2 instance is launched in a different region (eg us-east-2 ).

How can I achieve this?

One option is to put SNS as an event target and subscribe the lambda to the SNS topic. SNS supports cross region subscriptions.

Another option is to use cross region event busses. You create a rule that forwards the event to another region and create another event rule in that region that invokes a lambda. More info here: https://aws.amazon.com/blogs/compute/introducing-cross-region-event-routing-with-amazon-eventbridge/

There was a recently announced new functionality that can help with cross region use cases with aws lambda: https://aws.amazon.com/blogs/compute/introducing-cross-region-event-routing-with-amazon-eventbridge/

Amazon eventBridge is a great way for cross region (and cross-account) event processing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM