Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex in CloudWatch event pattern matching

Tags:

How can I match a CloudWatch event on a regex. I need to invoke only a particular SNS target on a specific job name. e.g, something like below where I want to do a regex match on TranscriptionJobName. Thanks.

{
  "source": [
    "aws.transcribe"
  ],
  "detail-type": [
    "Transcribe Job State Change"
  ],
  "detail": {
    "TranscriptionJobStatus": [
      "COMPLETED",
      "FAILED"
    ],
    "TranscriptionJobName": [
      "transcription-localhost-*"
    ]
  }
}
like image 219
user4848830 Avatar asked Feb 12 '19 19:02

user4848830


1 Answers

This is now possible with EventBridge and its ability to do prefix matching. This works for me. I have a Lambda function set up as a target, and the function is executed only upon a Transcribe job reaching COMPLETED status and having a job name starting with voicemail-.

{
  "source": [
    "aws.transcribe"
  ],
  "detail": {
    "TranscriptionJobName": [
      {
        "prefix": "voicemail-"
      }
    ],
    "TranscriptionJobStatus": [
      "COMPLETED"
    ]
  }
}
like image 59
ctc Avatar answered Oct 11 '22 16:10

ctc