0
votes

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
Thanks for the hint :)lars

2 Answers

2
votes

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

0
votes

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"
  ]
}