AWS CloudWatch Alarms to multiple EC2 instances

Adam W. picture Adam W. · Jan 23, 2014 · Viewed 9.1k times · Source

I'm wanting to apply a CloudWatch alarm to stop instances which aren't being used in our pre-production environment. We often have instances being spun up, used and then left turned on which is really starting to cost us a fair amount of money.

CloudWatch alarms have a handy feature whereby we can stop based on some metrics - this is awesome and what I'd like to use to constantly keep an eye on the servers with but let it tidy up the instances for me.

The problem with this is that it appears that the CloudWatch alarms need to be created individually against each instance. Is there a way in which I can create one alarm which would share values across all current and future instances which will be started?

ETA - Alternatively, tell me that these options are better than CloudWatch and I'll be happy at that.

AWS EC2 stop all through PowerShell/CMD tools

Answer

Chris Montanaro picture Chris Montanaro · Jan 23, 2014

Add a startup script that creates the CloudWatch alarm to the base image you use to generate your VMs.

http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CLIReference.html