简体   繁体   English

跨区域调用 CloudWatch 事件 lambda

[英]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.我在us-east-1中部署了一个 lambda function,它会在每次启动 EC2 实例时运行。 The lambda function is triggered with the following EventBridge configuration:使用以下 EventBridge 配置触发 lambda function:

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

The lambda function is working great. lambda function 运行良好。 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 ).现在,我希望扩展它,以便即使在不同区域(例如us-east-2 )启动 EC2 实例时也会触发我的 lambda function 。

How can I achieve this?我怎样才能做到这一点?

One option is to put SNS as an event target and subscribe the lambda to the SNS topic.一种选择是将 SNS 作为事件目标并将 lambda 订阅到 SNS 主题。 SNS supports cross region subscriptions. SNS 支持跨区域订阅。

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/您创建一个将事件转发到另一个区域的规则,并在该区域创建另一个调用 lambda 的事件规则。更多信息在这里: https:https://aws.amazon.com/blogs/compute/introducing-cross-region-event-路由与亚马逊事件桥/

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/最近宣布了一项新功能,可以帮助处理 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 Amazon eventBridge 是跨区域(和跨账户)事件处理的绝佳方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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