Beware: certain Amazon EC2 AMI’s terminate at shutdown

Linux
Internet
Author

Vinh Nguyen

Published

March 20, 2012

I toyed with Amazon EC2 last year by migrating my web server there. After issuing shutdown -P in Ubuntu last week, my instance disappeared from the list in the AWS dashboard. I seeked help and found out that some AMI's are set to terminate at shutdown. Unfortunately, the AMI I used was one of them. Files and settings are not recoverable after an instance is terminated. Luckily, I transferred most of my critical information out prior to the shutdown; I'm only missing one file. Note to self: for all future instances, the shutdown behavior to stop (as opposed to terminate) could be modified per these instructions. First, create and download the X.509 certificate and private key. To access the EC2 api, do the following on your computer:

sudo apt-get install ec2-api-tools ec2-ami-tools ##ec2-init

Then, do the following to find out what behavior is currently set on your instance:

ec2-describe-instance-attribute i-AMAZON-INSTANCE-ID --instance-initiated-shutdown-behavior -K /path/to/x509-key.pem -C /path/to/x509-cert.pem 

If the value is not stop, then do

ec2-modify-instance-attribute i-AMAZON-INSTANCE-ID -K /path/to/x509-key.pem -C /path/to/x509-cert.pem --instance-initiated-shutdown-behavior stop