1

I couldn't find a CloudWatch metric that was based on instance running time. Are there any readily available controls for AWS EC2 that could for example send me an email if an instance of type C3.4xlarge is on for more than 1.5 hours?

egekhter
  • 2,067
  • 2
  • 23
  • 32

1 Answers1

1

You could write a powershell script using the AWS CLI that does the following:

  1. Use the mon-put-data command to put a value of 0 into your Cloud Watch metric for the machine.
  2. Use the Start-Sleep cmdlet to wait for the duration of 90 minutes or whatever your time is
  3. Use the mon-put-data command to put a value of 1 into the metric
  4. Call the powershell script as a scheduled task on bootup to run without users having to be logged in.
  5. Setup an alarm on the cloud watch metric if the value of your custom metric is larger than 0.

Reference to Start-Sleep cmdlet: http://technet.microsoft.com/en-us/library/ee177002.aspx

Reference to Cloud Watch CLI: http://docs.aws.amazon.com/AmazonCloudWatch/latest/cli/cli-mon-put-data.html

Jason W
  • 13,026
  • 3
  • 31
  • 62