如何在 Cloudwatch Events 上使用正则表达式

How to use regex on Cloudwatch Events

在 Cloudwatch 事件中,我们可以在源、详细信息等方面编写过滤规则。我目前的做法是 如下所示,

  DefaultEventsRule:
    Type: AWS::Events::Rule
    Properties:
      Name: "CloudWatchRule1"
      Description: "Match events and send them to corresponding queue for delivery."
      EventPattern:
        {
          "source": ["xyz"],
          "resources":
              ...

是否可以对 source 进行正则表达式操作? 看起来不可能在事件上写正则表达式; SO 中还有另一个问题问类似的问题(对于 destination),解决方法是使用单独的规则,这似乎也是源代码的唯一方法。

参考:

目前不支持 RegEx。您最多可以使用 complex filterEventBridge 查看详细信息 content-filtering-with-event-patterns

另请参阅此 SO 问题中的答案, 对我有帮助。

希望AWS大佬们以后加RegEx matching