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

Last updated: 2019-07-12

I want to set up automatic recovery of an Amazon Elastic Compute Cloud (Amazon EC2) instance using Amazon CloudWatch. How can I do this?

Resolution

If your instance fails a system status check, you can use CloudWatch alarm actions to automatically recover it. The recover option is available for over 90% of deployed customer EC2 instances. For more information on supported instances, see Recover Your Instance.

Note: The CloudWatch recovery option works only for system check failures, not for instance status check failures. In addition, if you terminate your instance, then it can't be recovered.

If your instance fails a status check, you might need to reboot the instance or make configuration changes. For more information, see Types of Status Checks.

To configure a CloudWatch alarm action to automatically recover your instance

  1. In the Amazon EC2 console, choose Instances in the navigation pane, and then select the instance that you want to configure.
  2. Choose Actions, CloudWatch Monitoring, Add/Edit Alarms, and then choose Create Alarm.
  3. Choose Create topic.
  4. For Send a notification to field, type a topic name.
  5. For With these recipients field, type the email address.
    Note: The SNS topic or email address receives a subscription email that must be confirmed within three days. Notifications are sent only to confirmed addresses.
  6. Choose Take the action, and then choose Recover.
    Note: You can also choose Stop, Terminate, or Reboot.
  7. Choose your constraints, and then choose Create Alarm.

For additional information, see Create Alarms That Stop, Terminate, Reboot, or Recover an Instance.

Note: Be sure that the user who configured the alarm has AWS Identity and Access Management (IAM) permissions to stop and start the instance. For more information, see Creating IAM Roles.


Did this article help you?

Anything we could improve?


Need more help?