首页 > 解决方案 > CloudWatch 事件模式匹配中的正则表达式

问题描述

如何在正则表达式上匹配 CloudWatch 事件。我只需要在特定的作业名称上调用特定的 SNS 目标。例如,如下所示,我想对 TranscriptionJobName 进行正则表达式匹配。谢谢。

{
  "source": [
    "aws.transcribe"
  ],
  "detail-type": [
    "Transcribe Job State Change"
  ],
  "detail": {
    "TranscriptionJobStatus": [
      "COMPLETED",
      "FAILED"
    ],
    "TranscriptionJobName": [
      "transcription-localhost-*"
    ]
  }
}

标签: amazon-cloudwatchaws-event-bridge

解决方案


这现在可以通过 EventBridge 及其进行前缀匹配的能力来实现。这对我有用。我将 Lambda 函数设置为目标,该函数仅在 Transcribe 作业达到COMPLETED状态且作业名称以voicemail-.

{
  "source": [
    "aws.transcribe"
  ],
  "detail": {
    "TranscriptionJobName": [
      {
        "prefix": "voicemail-"
      }
    ],
    "TranscriptionJobStatus": [
      "COMPLETED"
    ]
  }
}

推荐阅读