How to Modify the Instance Initiated Shutdown Behavior

How to Modify the Instance Initiated Shutdown Behavior

AWS has two types of AMIs: Instance Store backed and EBS backed. The EBS backed instance can be started or stopped using AWS APIs or the console. The user can configure the application by connecting to the instance. In certain cases, the user can shutdown the instance from the OS directly. The present guide demonstrates how to change the instance initiated shutdown behavior. This is applicable to only the EBS backed instance and when the instance is shut down internally.

For example, from Windows the user can shut down through the Start Menu (For OS Win 7 and before) or through shutdown from Linux. When the user shuts down the instance internally from the OS, by default the instance gets stopped. AWS provides a functionality, whereby the user can change the default shut down behavior such that when the instance is shut down internally, the instance gets terminated instead.

1. Go to the AWS console and select the EC2 service. From the EC2 dashboard, click on the “Running Instances” or “Instances” link.

2. Select the instance for which the shutdown behavior is required to be changed. Click on the “Actions” menu.

3. Select “Change Shutdown Behavior” from the “Actions” menu.

4. AWS will show the current shutdown behavior and ask the user to change if required. Change the shutdown behavior to “Terminate”. Select the “Yes, Change” button.

5. The shutdown behavior will be changed to terminate.

6. Launch an AWS instance. Login to the instance.

7. If it is a Linux instance, run the command “shutdown –h now”. In Windows, shutdown the machine using the “Start Menu” (Win 2007 Serves). The instance will start shutting down.

8. AWS will show the instance status as shutting down.

9. When the instance shuts down, if the shut down behavior is not set, AWS will stop the instance. Here, the user has set the shutdown behavior in step#4. Thus, AWS will terminate the instance.

10. To run the above mentioned steps through the command line interface, first setup AWS EC2 CLI to launch an instance with the command line option, as explained here.

11. Run the command:

 ec2-describe-instance-attribute  --instance-initiated-shutdown-behavior.

Run the command:

 ec2-modify-instance-attribute  --instance-initiated-shutdown-behavior terminate

to change the shutdown behavior to terminate.

12. The actual output of the above mentioned commands is shown below:

Keywords: Amazon web services, Amazon AWS console, Amazon AWS instances, EC2 Service, Amazon cloud computing, EC2 EBS, Instance Store Backed, EBS Backed Instance, AMI

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations