| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
By default, when you initiate a shutdown from within an EBS-backed instance, the instance
stops. You can change this so the instance terminates instead. You just modify the
InstanceInitiatedShutdownBehavior attribute for the instance. You can
do this while the instance is either running or stopped.
Note
This termination process
will occur no matter what the DisableApiTermination
attribute is set to. For more information about the
DisableApiTermination attribute, see Enabling Termination Protection for an
Instance.
Caution
When an AMI is created from an instance, the
InstanceInitiatedShutdownBehavior attribute for the instance is also
stored in the AMI. Any instances created from that AMI will inherit the
InstanceInitiatedShutdownBehavior attribute. This can result in
instances being inadvertently terminated when they are shut down from within the
instance. You cannot change this attribute in the AMI, but you can change it in
the launched instance. The best practice is to always set the
InstanceInitiatedShutdownBehavior attribute of an instance to
stop before creating an AMI from the instance.
To change the Shutdown Behavior
Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Click Instances in the navigation pane.
Context-click on the instance you want to modify and select Change Shutdown Behavior.
Select either Terminate or Stop from the Shutdown Behavior drop-down list.

Click Yes, Change.
You can toggle the attribute between Stop and Terminate as often as you want.
To change the instance-initiated-shutdown-behavior attribute
View the current value for the attribute with the ec2-describe-instance-attribute command.
PROMPT>ec2-describe-instance-attributeinstance_id--instance-initiated-shutdown-behavior
Sample response:
instanceInitiatedShutdownBehavior i-87ad5eec stop
Change the attribute value to terminate with the ec2-modify-instance-attribute command.
PROMPT>ec2-modify-instance-attributeinstance_id--instance-initiated-shutdown-behavior terminate
Sample response:
instanceInitiatedShutdownBehavior i-87ad5eec terminate
You can toggle the attribute between stop and terminate as often as you
want.
To change the InstanceInitiatedShutdownBehavior attribute
Call the DescribeInstanceAttribute action to get the current value of the attribute.
https://ec2.amazonaws.com/ ?Action=DescribeInstanceAttribute &InstanceId=i-87ad5eec &Attribute=instanceInitiatedShutdownBehavior &AUTHPARAMS
For information about the auth parameters, see Common Query Parameters in the Amazon EC2 API Reference.
The following is an example response.
<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<instanceId>i-5d7e8e36</instanceId>
<instanceInitiatedShutdownBehavior>
<value>stop</value>
</instanceInitiatedShutdownBehavior>
</DescribeInstanceAttributeResponse>Call the ModifyInstanceAttribute action to change the attribute's value.
https://ec2.amazonaws.com/ ?Action=ModifyInstanceAttribute &InstanceId=i-87ad5eec &Attribute=instanceInitiatedShutdownBehavior &Value=terminate &AUTHPARAMS
The following is an example response.
<ModifyInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </ModifyInstanceAttributeResponse>
You can toggle the attribute between stop and terminate as often as you
want.