1

I have implemented a basic combination of an AWS Eventbridge rule and a Lambda function as its target. The rule is suppose to create an event based on all AWS AutoScaling events and invoke the Lambda. This works well when triggering a scaling action for an existing ASG, but when creating a new ASG with the same prefix the rule is not reacting. Old ASG name: test-asg-lc-123 New ASG name: test-asg-lc-124

Is it even possible to use a wildcard?

  "detail": {
    "AutoScalingGroupName": [
      "test-asg-lc-*"
    ]
  },
  "detail-type": [
    "EC2 Instance Launch Successful",
    "EC2 Instance Terminate Successful",
    "EC2 Instance Launch Unsuccessful",
    "EC2 Instance Terminate Unsuccessful",
    "EC2 Instance-launch Lifecycle Action",
    "EC2 Instance-terminate Lifecycle Action",
    "EC2 Auto Scaling Instance Refresh Checkpoint Reached"
  ],
  "source": [
    "aws.autoscaling"
  ]
}
2
  • When figuring out event patterns I recommend using aws events test-event-pattern which allows you to verify that a pattern matches a given event. "The matching is exact (character-by-character), without case-folding or any other string normalization." docs.aws.amazon.com/AmazonCloudWatch/latest/events/…
    – luk2302
    Commented Mar 25, 2021 at 13:46
  • Thanks for the hint :)
    – lars
    Commented Mar 25, 2021 at 15:37

2 Answers 2

2

It looks like wildcard is not supported in this case. AWS documentation mentions The matching is exact (character-by-character), without case-folding or any other string normalization. and no * or wildcard is mentioned in the documentation.

Reference: https://docs.aws.amazon.com/eventbridge/latest/userguide/filtering-examples-structure.html

You can follow Prefix Matching mentioned in this documentation https://docs.aws.amazon.com/eventbridge/latest/userguide/content-filtering-with-event-patterns.html#filtering-prefix-matching

1
  • 1
    Wow, big kudos to you. I did not know that prefixes existed for that. Therefore thanks a lot. It turns out there is a small downside working with prefixes, EventBridge still seems to have trouble working with two ASGs. No event is triggered when the new ASG is created, but only on the deletion of the old ASG. After the old ASG is gone, it can process scaling events from the new ASG. A bit weird. Hope you are fine with me posting the answer in the answer section.
    – lars
    Commented Mar 25, 2021 at 15:16
1

Based on @Husyns answer, big thanks to him, I want to share a working solution with some limitations (what limitations, please view the comment below Husyns answer).

{
  "detail-type": [
    "EC2 Instance Launch Successful",
    "EC2 Instance Terminate Successful"
  ],
  "detail": {
    "AutoScalingGroupName": [
      {
        "prefix": "test-asg-lc-"
      }
    ]
  },
  "source": [
    "aws.autoscaling"
  ]
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.