9uzman7
9uzman7

Reputation: 488

Terminate entire aws auto scaling group from cloudwatch alarm action

I have an AWS auto scaling group. From the instances I collect a variety of metrics and placed some cloud watch alarms on these metrics. In specific scenarios I would like to add a cloud watch alarm action that terminates the entire auto scaling group. Is this possible? I am going over aws documentation but does not seem to be possible.

Thanks!!

Upvotes: 0

Views: 61

Answers (1)

mcfinnigan
mcfinnigan

Reputation: 11638

You can do this by invoking Lambda from your custom Cloudwatch event

You will need to write a Lambda that can use STS to assume a role that permits it to issue an EC2 Terminate command

The workflow would be:

  1. Cloudwatch event triggers
  2. Lambda function is invoked
  3. Lambda function assumes role via STS
  4. Lambda function retrieves list of instances in the ASG
  5. Lambda function cycles through instances, issuing termination commands

Upvotes: 1

Related Questions