Skip to content

How do I initiate automatic recovery when my Amazon EC2 instance fails a status check?

4 minute read
0

I want to initiate an automatic recovery action when my Amazon Elastic Compute Cloud (Amazon EC2) instance fails a status check.

Short description

Automatic recovery can recover an EC2 instance when it fails a system status check. An instance failure during a system status check typically means that there's an AWS hardware issue. However, automatic recovery can't recover an instance that fails an instance status check. For more information about these checks, see Types of status checks.

Note: Only certain instance types support automatic recovery actions.

Resolution

To automatically recover your instance, use one of the following methods:

  • Simplified automatic recovery based on instance configuration
  • Amazon CloudWatch action based recovery

Simplified automatic recovery based on instance configuration

By default, all instances that support simplified automatic recovery are configured to recover failed instances.

Verify that you meet the simplified automatic recovery prerequisites. You can complete the following actions during instance launch, or after you launch your instance.

To turn off simplified automatic recovery during instance launch, complete the following steps:

  1. Open the Amazon EC2 console.
  2. Choose Launch instance.
  3. Under Advanced details, turn off Instance auto-recovery.
  4. Configure your settings, and then launch the instance.

To set the automatic recovery behavior to default for instances in the Running or Stopped states, complete the following steps:

  1. Open the Amazon EC2 console.
  2. In the navigation pane, choose Instances.
  3. Select the instance, and then choose Actions.
  4. Choose Instance settings, and then for Change auto-recovery behavior, choose Default (On).
    Note: To turn off automatic recovery, turn off Change auto-recovery behavior.
  5. Choose Save.

To review the results of the simplified automatic recovery, check the AWS Health Dashboard event. Example notifications:

  • Failed events: AWS_EC2_SIMPLIFIED_AUTO_RECOVERY_FAILURE
  • Successful events: AWS_EC2_SIMPLIFIED_AUTO_RECOVERY_SUCCESS

CloudWatch action based recovery

Use CloudWatch action based recovery to choose when you want to recover your instance. When an event invokes the StatusCheckFailed_System alarm, CloudWatch initiates the recover action. Then, the Amazon Simple Notification Service (Amazon SNS) topic sends the notification that you chose when you created the alarm.

Important: As part of instance recovery, Amazon EC2 migrates the instance during an instance reboot. Data that's in-memory is lost.

After the instance recovery process completes, CloudWatch publishes information to the SNS topic. Subscribers to the SNS topic receive an email notification with the recovery attempt status and further instructions. Successful recovery appears as an instance reboot on the recovered instance.

Verify that your configuration meets the requirements for CloudWatch action based recovery. To configure automatic recovery on your instance, configure a CloudWatch alarm for recover actions.

Test and verify automatic recovery

You can't test automatic recovery from end to end. Only AWS infrastructure detects system status check failures (StatusCheckFailed_System). These failures reflect actual hardware or platform-level events on the underlying host. No customer-facing mechanism can artificially cause a StatusCheckFailed_System condition. This includes AWS Fault Injection Simulator (AWS FIS), CloudWatch APIs, and all other customer-facing APIs. The AWS FIS AZ Availability: Power Interruption scenario uses the aws:ec2:stop-instances and capacity-error actions. These actions don't cause CloudWatch to detect a StatusCheckFailed_System alarm state. They also don't exercise the automatic recovery migration path.

For CloudWatch action based recovery, use the AWS CLI set-alarm-state command to verify that the CloudWatch alarm action fires correctly. For example, you can confirm that the alarm changes state and invokes the recover action. This method validates only the alarm action invocation. It doesn't exercise the actual automatic recovery detection or instance migration path.

For simplified automatic recovery, there's no equivalent workaround. Simplified automatic recovery operates entirely within AWS infrastructure. It has no customer-configurable CloudWatch alarm. You can verify simplified automatic recovery only after a real infrastructure event occurs. Review the AWS_EC2_SIMPLIFIED_AUTO_RECOVERY_SUCCESS or AWS_EC2_SIMPLIFIED_AUTO_RECOVERY_FAILURE events in the AWS Health Dashboard.

Related information

Recover your instance

Status checks for Amazon EC2 instances

AWS OFFICIALUpdated 2 years ago