Using wildcard in Custom event pattern for the event SSM parameter
Asked Answered
R

1

7

I am having a lambda function that trigger a Jenkins job. I want to invoke this lambda when a new ssm parameter is added. I have added the below Custom event pattern in the cloud-watch event pattern.

{
  "source": [
    "aws.ssm"
  ],
  "detail-type": [
    "Parameter Store Change",
    "Parameter Store Policy Action"
  ],
  "detail": {
      "name": [
          "/dev/*"
        ],
        "operation": [
          "Create",
          "Update",
          "Delete",
          "LabelParameterVersion"
  ]

}

}

This means, the lambda need to trigger if i create a ssm parameter start with "/dev/anystring" But the lambda is not triggering if i provide wild card. Any suggestion on this.?

Rootstock answered 9/1, 2020 at 13:41 Comment(0)
T
13

In this case you want to use the prefix comparison operator to filter based on values in the detail.name field.

{
  "source": [
    "aws.ssm"
  ],
  "detail-type": [
    "Parameter Store Change",
    "Parameter Store Policy Action"
  ],
  "detail": {
    "name": [ { "prefix": "/dev/" } ],
    "operation": [
      "Create",
      "Update",
      "Delete",
      "LabelParameterVersion"
    ]
  }
}

For more details, see Reducing custom code by using advanced rules in Amazon EventBridge, especially example 2. All ATMs in New York City in the section Filtering events in a custom application.

I am contributing this on behalf of my employer, Amazon. My contribution is licensed under the MIT license. See here for a more detailed explanation.

Torsk answered 6/2, 2020 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.