Certopolis

AWS Certified CloudOps Engineer – Associate

CloudWatch alarm EC2 actions: stop, terminate, reboot, recover

The EC2 User Guide lists four alarm actions for an instance. Stop and terminate are for instances you no longer need running. Reboot is recommended when the instance status check fails. Recover is for a failed system status check: it moves the instance to other hardware and keeps its instance ID and IP addresses.

When do you use stop or terminate?

Both save money on instances that sit idle, for example an alarm on low average CPU over a set time. A stopped instance can be started again later and keeps its instance ID and root volume. A terminated instance cannot be started; you launch a new one.

Only instances with an EBS root volume can be stopped. An instance with an instance store root volume can only be terminated. Data on instance store volumes is lost on stop and on terminate. A terminate action works only when termination protection is not enabled on the instance.

Reboot or recover: which status check failed?

The reboot action is recommended for instance status check failures. It is the same as an operating system reboot. The instance stays on the same physical host, so it keeps its public DNS name, its private IP address and the data on its instance store volumes.

The recover action is for system status check failures, which point to the host's hardware or software and not to the instance itself. It is configured as an alarm on StatusCheckFailed_System. AWS moves the instance to a different host. The recovered instance keeps its instance ID, private, public and Elastic IP addresses, instance metadata, placement group and attached EBS volumes.

Recovery loses what is in memory, and CloudWatch action based recovery also loses data on instance store volumes. Automatic recovery does not operate when only the instance status check fails.

What limits apply to recovery and to alarm actions?

CloudWatch action based recovery works only on supported instance types. If instance store volumes were added at launch, only M3, C3, R3, X1, X1e, X2idn and X2iedn are supported. It is not supported for instances in an Auto Scaling group, instances on a Dedicated Host, or instances that use an Elastic Fabric Adapter. Simplified automatic recovery is a separate mechanism that is enabled by default at launch on supported instances.

EC2 actions can be added to any alarm on a per-instance EC2 metric, including custom metrics that carry the InstanceId dimension. Alarm actions run only when the alarm changes state. They are not repeated while the condition persists. Auto Scaling actions are the exception.

Status check alarms can briefly enter INSUFFICIENT_DATA when metric reporting is interrupted, even on a healthy instance. AWS recommends treating missing data as missing and running stop, terminate, reboot or recover only in the ALARM state.

Where the exam catches people

  • Believing recover fixes an operating system fault: recovery acts on system status check failures. An instance status check failure calls for the reboot action.
  • Believing a recovered instance gets a new ID or address: it keeps its instance ID and its private, public and Elastic IP addresses.
  • Believing a reboot moves the instance to new hardware: a rebooted instance stays on the same physical host.
  • Believing an alarm notifies again every period while it stays in ALARM: actions run on state changes only, except Auto Scaling actions.
  • Believing any instance can be stopped by an alarm: an instance with an instance store root volume can only be terminated.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A standalone Amazon EC2 instance runs a reporting service. Twice this month the instance status check failed after the operating system ran out of memory, while the system status check kept passing. Each time an operator restarted the instance by hand and it recovered. The SysOps administrator wants this restart done automatically the next time. Which solution will meet this requirement?

    Right. In the game that’s Renown for your Monitoring, Logging, Analysis, Remediation, and Performance Optimization building.

    Not that one: D is right. In the game your Monitoring, Logging, Analysis, Remediation, and Performance Optimization building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    An alarm on StatusCheckFailed_Instance with that action restarts the instance on the same host.

    Written from docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingAlarmActions.html

  2. Developers often leave their EBS-backed Amazon EC2 test instances running overnight. A SysOps administrator wants each instance shut down automatically when its CPU utilization stays below 5 percent for two hours. A developer must be able to start the instance again the next morning with the same instance ID and root volume. Which action should the SysOps administrator take to meet these requirements?

    Right. In the game that’s Renown for your Monitoring, Logging, Analysis, Remediation, and Performance Optimization building.

    Not that one: C is right. In the game your Monitoring, Logging, Analysis, Remediation, and Performance Optimization building would lose a little Renown, and this question would come back later.

  3. A company runs an in-memory cache on one Amazon EC2 X2idn instance that uses its instance store volume, added at launch, for scratch data. The cache reloads itself after any restart. If the underlying host fails, the instance must move to healthy hardware automatically and keep its instance ID and Elastic IP address. Which action should the SysOps administrator take to meet these requirements?

    Right. In the game that’s Renown for your Monitoring, Logging, Analysis, Remediation, and Performance Optimization building.

    Not that one: B is right. In the game your Monitoring, Logging, Analysis, Remediation, and Performance Optimization building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Recovery moves the instance to new hardware and keeps its instance ID, Elastic IP address and EBS volumes; RAM and instance store data are lost, which this cache tolerates because it reloads.

    Written from docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-recover.html

Ask for something