| Did this page help you? Yes No Tell us about it... |
![]() | Note |
|---|---|
The following information applies to instances of Amazon EBS-backed AMIs or Amazon EC2 instance store-backed AMIs. |
By default, you can terminate any instances you launch. If you want to prevent
accidental termination of the instance, you can enable termination
protection for the instance. The instance's
DisableApiTermination attribute controls whether the instance is
protected. A value of true means the instance is protected and can't be
terminated; a value of false means it's not protected and can be
terminated. You can specify whether an instance is protected either at launch time or
after the instance is running. You can modify this attribute while the instance is
running or stopped (for Amazon EBS-backed instances).
By default, termination protection is disabled for an instance at launch time.
To enable termination protection for an instance at launch time
In the Request Instances Wizard, select the check box for Termination Protection.

To enable termination protection for an instance after it's launched
In your list of instances, right-click the instance and select Change Termination Protection.
A confirmation dialog box appears with the current status of termination protection.
Click Yes, Enable.
Now the instance cannot be terminated until you disable termination protection.
You can use the same procedure to disable termination protection for the instance. You can enable and disable this attribute of an instance as often as you want.
By default, termination protection is disabled for an instance at launch time.
To enable termination protection for an instance at launch time
Add --disable-api-termination to the
ec2-run-instances command.
PROMPT>ec2-run-instancesami_id--disable-api-termination ...
To enable termination protection for an instance after it's launched
View the current value for the attribute with the following command.
PROMPT>ec2-describe-instance-attributeinstance_id--disable-api-termination
Following is a sample response.
disableApiTermination i-87ad5eec false
Enable termination protection with the following command.
PROMPT>ec2-modify-instance-attributeinstance_id--disable-api-termination true
Following is a sample response.
disableApiTermination i-87ad5eec true
To disable termination protection for an instance
Disable termination protection for the instance with the following command.
PROMPT>ec2-modify-instance-attributeinstance_id--disable-api-termination false
Following is a sample response.
disableApiTermination i-87ad5eec false
You can enable and disable this attribute of an instance as often as you want.
By default, termination protection is disabled for an instance at launch time.
To enable termination protection for an instance at launch time
Issue a Query request for RunInstances similar to the
following example and include
DisableApiTermination=true.
https://ec2.amazonaws.com/?Action=RunInstances &ImageId=ami-60a54009 &MaxCount=3 &MinCount=1 &DisableApiTermination=true &Placement.AvailabilityZone=us-east-1b &Monitoring.Enabled=true &AUTHPARAMS
For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference.
To enable termination protection for an instance after it's launched
Issue the following Query request to get the current value of the
disableApiTermination attribute.
https://ec2.amazonaws.com/ ?Action=DescribeInstanceAttribute &InstanceId=i-87ad5eec &Attribute=disableApiTermination &AUTHPARAMS
Following is an example response.
<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<instanceId>i-87ad5eec</instanceId>
<disableApiTermination>
<value>false</value>
</disableApiTermination>
</DescribeInstanceAttributeResponse>Issue the following Query request to modify the
disableApiTermination attribute.
https://ec2.amazonaws.com/ ?Action=ModifyInstanceAttribute &InstanceId=i-87ad5eec &DisableApiTermination.Value=true &AUTHPARAMS
Following is an example response.
<ModifyInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </ModifyInstanceAttributeResponse>
To disable termination protection for an instance
Issue the following Query request to modify the
disableApiTermination attribute.
https://ec2.amazonaws.com/ ?Action=ModifyInstanceAttribute &InstanceId=i-87ad5eec &DisableApiTermination.Value=false &AUTHPARAMS
Following is an example response.
<ModifyInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/"> <return>true</return> </ModifyInstanceAttributeResponse>
You can enable and disable this attribute of an instance as often as you want.