To store your server’s state (once it’s all set up), you can create an image of it and store it in S3. After doing this, you can launch the image as an instance (or fifty bajillion instances if you so choose).
First, make sure the cert-#.pem and pk-#.pem files are in your root directory.
We begin with
scp -i id_rsa-gsg-keypair pk-#.pem cert-#.pem root@your_public_dns.amazonaws.com:/mnt
Replace # with the filename and “your_public_dns” with… well, the public dns for this instance.

Next, we’ll bundle this thing.
ec2-bundle-vol -d /mnt -k /mnt/pk-#.pem -c /mnt/cert-#.pem -u account_id -r i386 -p the_image_name
Replace # with the filename.

Note: Replace “account_id” with your account number (don’t include the “-”).

And upload it onto S3. At this point you will be charged for storage.
ec2-upload-bundle -b very_unique_id -m /mnt/the_image_name.manifest.xml -a access_key_id -s secret_access_key
Replace “very_unique_id” with the bucket name. This can’t someone else’s existing bucket so use a unique name.

Note: The “access_key_id” and “secret_access_key” can be found in your AWS account.

Finally, we have to register this image with Amazon. If you try to run from your EC2 instance, you may get a “command not found” message. ec2-register is part of the API tools (as opposed to the AMI tools). If this happens, you can just run it from your local computer (as explained here).
ec2-register very_unique_id/the_image_name.manifest.xml
Replace “very_unique_id” with the bucket name and “the_image_name” with what you chose above. You will be given an image ID. You can use this to filter the AMI’s in ElasticFox to find your new AMI - and it’s ready to launch!


0 Comments until now
Add your Comment!