Skip to content

How do I set up a CloudWatch alarm to automatically recover my EC2 instance?

2 minute read
0

I want to use Amazon CloudWatch to set up automatic recovery of an Amazon Elastic Compute Cloud (Amazon EC2) instance.

Short description

If your instance fails a system status check, then you can use CloudWatch alarm actions to automatically recover your Amazon EC2 instance. The recover option is available for over 90% of deployed EC2 instances. However, the recover option works only for system check failures, not for instance status check failures. In addition, you can't recover an instance that you terminate.

If your instance fails a status check, then you might need to reboot the instance or change the configuration.

Resolution

Create an alarm

  1. Open the EC2 console.
  2. In the navigation pane, choose Instances.
  3. Select the instance that you want to configure.
  4. Choose Actions, and then choose Monitor and troubleshoot. Then, choose Manage CloudWatch alarms.
  5. Choose Create an alarm.
    Note: To create an alarm, you must have AWS Identity and Access Management (IAM) permissions to stop and start the associated instance. For more information, see IAM role creation.
  6. For Alarm notification, choose an existing Amazon Simple Notification Service (Amazon SNS) topic. To create a new topic, see Creating an Amazon SNS topic.
    Note: To receive notifications when an alarm enters the ALARM state, you must subscribe to the SNS topic.
  7. Turn on Alarm action, and then choose Recover.
  8. For Group samples by and Type of data to sample, choose an appropriate statistic and metric for your use case.
  9. For Consecutive period and Period, specify the evaluation period for the alarm.
  10. (Optional) Modify the automatically created Alarm name.
  11. Choose Create.

Set alarm for reboot

  1. Open the CloudWatch console.
  2. In the navigation pane, choose All Alarms.
  3. Select the alarm that you created.
  4. Choose Action, and then choose Edit.
  5. In the Additional Configuration section, select Treat missing data as bad (breaching threshold).
  6. Choose Save.

Related information

Create alarms that stop, terminate, reboot, or recover an instance

1 Comment

This article was reviewed and updated on 2026-03-16.

AWS
MODERATOR
replied 2 months ago

Relevant content