Amazon Elastic Compute Cloud
User Guide (API Version 2012-04-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Changing the Instance Initiated Shutdown Behavior

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.

Command Line tools

To change the InstanceInitiatedShutdownBehavior attribute

  1. View the current value for the flag with the following command.

    PROMPT>  ec2-describe-instance-attribute instance_id --instance-initiated-shutdown-behavior

    Sample response:

    instanceInitiatedShutdownBehavior      i-87ad5eec      stop
  2. Change the flag's value to terminate with the following command.

    PROMPT>  ec2-modify-instance-attribute instance_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.

API

To change the InstanceInitiatedShutdownBehavior attribute

  1. Issue the following Query request to get the current value of the attribute.

    https://ec2.amazonaws.com/
    ?Action=DescribeInstanceAttribute
    &InstanceId=i-87ad5eec
    &Attribute=instanceInitiatedShutdownBehavior
    &...auth parameters...

    For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference.

    Following is an example response.

    <DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
       <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
       <instanceId>i-5d7e8e36</instanceId>
       <instanceInitiatedShutdownBehavior>
          <value>stop</value>
       </instanceInitiatedShutdownBehavior>
    </DescribeInstanceAttributeResponse>
  2. Issue the following Query request to change the attribute's value.

    https://ec2.amazonaws.com/
    ?Action=ModifyInstanceAttribute
    &InstanceId=i-87ad5eec
    &Attribute=instanceInitiatedShutdownBehavior
    &Value=terminate
    &...auth parameters...

    Following is an example response.

    <ModifyInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-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.