0

我已经实现了 AWS Eventbridge 规则和 Lambda 函数的基本组合作为其目标。该规则假设基于所有 AWS AutoScaling 事件创建一个事件并调用 Lambda。这在为现有 ASG 触发缩放操作时效果很好,但在创建具有相同前缀的新 ASG 时,规则没有反应。旧 ASG 名称:test-asg-lc-123 新 ASG 名称:test-asg-lc-124

甚至可以使用通配符吗?

  "detail": {
    "AutoScalingGroupName": [
      "test-asg-lc-*"
    ]
  },
  "detail-type": [
    "EC2 Instance Launch Successful",
    "EC2 Instance Terminate Successful",
    "EC2 Instance Launch Unsuccessful",
    "EC2 Instance Terminate Unsuccessful",
    "EC2 Instance-launch Lifecycle Action",
    "EC2 Instance-terminate Lifecycle Action",
    "EC2 Auto Scaling Instance Refresh Checkpoint Reached"
  ],
  "source": [
    "aws.autoscaling"
  ]
}
4

2 回答 2

2

在这种情况下,似乎不支持通配符。AWS 文档中提及The matching is exact (character-by-character), without case-folding or any other string normalization.,但文档中未提及 * 或通配符。

参考:https ://docs.aws.amazon.com/eventbridge/latest/userguide/filtering-examples-structure.html

您可以遵循本文档中提到的前缀匹配https://docs.aws.amazon.com/eventbridge/latest/userguide/content-filtering-with-event-patterns.html#filtering-prefix-matching

于 2021-03-25T13:45:20.723 回答
0

基于@Husyns 的回答,非常感谢他,我想分享一个有一些限制的工作解决方案(有什么限制,请查看 Husyns 回答下面的评论)。

{
  "detail-type": [
    "EC2 Instance Launch Successful",
    "EC2 Instance Terminate Successful"
  ],
  "detail": {
    "AutoScalingGroupName": [
      {
        "prefix": "test-asg-lc-"
      }
    ]
  },
  "source": [
    "aws.autoscaling"
  ]
}
于 2021-03-25T15:20:08.840 回答