I have setup aws cloud watch
Here is below detail set in our cloud watch
- Metric name: CPUUtilization
- Statistic: average
- Period: 5 min
- Threshold Type: Static
- Whenever CPUUtilization is Lower/Equal then 10
- Datapoints to alarm: 1 out of 1
- Missing data treatment: Treat missing data as missing
EC2 action:
- Alarm state trigger: In Alarm
- Take the following action: stop this instance
After 5 min our server still does not stop with the cloud watch in aws.
You can use CloudWatch Events to trigger a Lambda that will perform the stop instance call on the ec2 instance.