Enable stop protection for your EC2 instances
To prevent an instance from being accidentally stopped, you can enable stop protection for the instance. Stop protection also protects your instance from accidental termination.
The DisableApiStop
attribute of the Amazon EC2 ModifyInstanceAttribute
Considerations
-
Enabling stop protection does not prevent you from accidentally stopping an instance by initiating a shutdown from the instance using an operating system command such as shutdown or poweroff.
-
Enabling stop protection does not prevent AWS from stopping the instance when there is a scheduled event to stop the instance.
-
Enabling stop protection does not prevent Amazon EC2 Auto Scaling from terminating an instance when the instance is unhealthy or during scale-in events. You can control whether an Auto Scaling group can terminate a particular instance when scaling in by using instance scale-in protection.
-
Stop protection not only prevents your instance from being accidentally stopped, but also from accidental termination when using the console, AWS CLI, or API. However, it does not automatically set the
DisableApiTermination
attribute. Note that when theDisableApiStop
attribute is set tofalse
, theDisableApiTermination
attribute setting determines whether the instance can be terminated using the console, AWS CLI, or API. For more information see Terminate Amazon EC2 instances. -
You can't enable stop protection for instance store-backed instances.
-
You can't enable stop protection for Spot Instances.
-
The Amazon EC2 API follows an eventual consistency model when you enable or disable stop protection. This means that the result of running commands to set the stop protection attribute might not be immediately visible to all subsequent commands you run. For more information, see Eventual consistency in the Amazon EC2 Developer Guide.
Stop protection tasks
Enable stop protection for an instance at launch
You can enable stop protection for an instance when launching the instance using one of the following methods.
Enable stop protection for a running or stopped instance
You can enable stop protection for an instance while the instance is running or stopped using one of the following methods.
Disable stop protection for a running or stopped instance
You can disable stop protection for a running or stopped instance using one of the following methods.