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.