Using Amazon CloudWatch, we will first create a rule that detects when an EC2 instance state changes to a running state. Follow these steps:
- From the Amazon CloudWatch dashboard, select Rules under Events from the left menu:
- Next, select Create Rule, and the following screen will be displayed:
- Using the drop-down list, select EC2 for Service Name.
- For Event Type, you can select EC2 Instance State-change Notification:
- Select running under the Specific state(s) drop-down list.
- Select Any instance. Your event pattern is now configured to record any events where an EC2 instance is listed as running, and this can be seen under Event Pattern Preview:
Now that you have identified which event(s) you want to capture, you need to configure the response to those events.