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 过滤事件?
1 Antwort
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
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen