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?
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
- In the Amazon EC2 console, choose Instances in the navigation pane, and then select the instance that you want to configure.
- Choose Actions, CloudWatch Monitoring, Add/Edit Alarms, and then choose Create Alarm.
- Choose Create topic.
- For Send a notification to field, type a topic name.
- 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.
- Choose Take the action, and then choose Recover.
Note: You can also choose Stop, Terminate, or Reboot.
- 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.