EventBridge异常如何处理和debug?

0

【以下的问题经过翻译处理】 我正在尝试基于 Ec2 标签 "key"(使用 EventBridge)触发事件但失败了。

{ "source": ["aws.ec2"], "detail-type": ["EC2 Instance State-change Notification"], "detail": { "state": ["running"], } }

这个会创建事件,但是 { "source": ["aws.ec2"], "detail-type": ["EC2 Instance State-change Notification"], "detail": { "state": ["running"], "tags": ["Name"] } }

不行。我根据 Cloudtrail 事件获取了这个 json。

"tagSpecificationSet": { "items": [ { "resourceType": "instance", "tags": [ { "key": "Name", "value": "Instance3" } ] } ] },

问题是:

  • 我觉得问题在于事件模式匹配以及我没有正确的源
  • 顺便说一下,事件变更通知中的示例事件没有 TAG。因此,是否可能使用 EventBridge 基于 TAG 过滤事件?
profile picture
专家
已提问 5 个月前19 查看次数
1 回答
0

【以下的回答经过翻译处理】 你这个应该是没有包含“Key”。可以这样(我是根据你的示例编写的,没有检查实际事件的样子):

{
  "source": ["aws.ec2"],
  "detail-type": ["EC2 Instance State-change Notification"],
  "detail": { 
    "state": ["running"],
    "tagSpecificationSet": {
      "items": {
        "tags": {
          "key": ["Name"]
        }
      }
    }
  }
}

请注意,以上模式将匹配任何Key = Name的标记。我假设你有一个与Name = Instance3相匹配的规则。但是,两个属性相关联的这种情况不受EventBridge Rules的支持。如果你想捕捉与Name标记相关的实例事件,这样可以实现。

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则