0

I want to monitor my EC2 instance state (running or stop) and set alarm in case, EC2 stop. My EC2 will run only from 9AM to 6PM. Can i accomplish above through cloudwatch and how ?

1 Answers1

0

You could use CloudWatch Event Schedule Expressions rule:

You can create rules that self-trigger on an automated schedule in CloudWatch Events using cron or rate expressions. All scheduled events use UTC time zone and the minimum precision for schedules is 1 minute.

For example.

One rule would start the instance at 9 AM from MON-FRY

0 9 ? * MON,TUE,WED,THU,FRI *

enter image description here

Other rule would stop the instance

0 18 ? * MON,TUE,WED,THU,FRI *

enter image description here

For starting the instance you would need to create a lambda function. For stopping you call StopInstance API directly using CloudWatch trigger:

enter image description here

Marcin
  • 215,873
  • 14
  • 235
  • 294