Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using wildcard in Custom event pattern for the event SSM parameter

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.?

like image 786
manu thankachan Avatar asked Jan 09 '20 13:01

manu thankachan


People also ask

What is the difference between CloudWatch and EventBridge?

CloudWatch Events provides a default event bus that exists in every AWS account. All AWS events are routed via the default bus. You can also choose to publish your custom events to the default bus. EventBridge introduces custom event buses you can use exclusively for your own workloads.

What is Event pattern?

An event pattern is one of the key concepts used in many advanced real-time analytics approaches, particularly CEP systems. It captures relationships between events in the real world.


1 Answers

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.

like image 186
Rob S. Avatar answered Sep 20 '22 13:09

Rob S.