Create an Amazon Machine Image

Building an AMI is essentially a way for you to backup and share the Amazon EC2 Instance that you've created. It is also useful for creating a fall-back point if an installation or process goes awry, and you'd like to revert to a previous state.

Prepare to Bundle

  1. You'll need to locate a few things:
    1. The private key that identifies your Amazon Web Services account. This is a .pem file.
    2. The public key that identifies your Amazon Web Services account. This is also a .pem file.
    3. Your Amazon Web Services Account number.
    4. Your Amazon Web Services Password and Super-Secret Password.
  2. Put the two .pem files somewhere accessible from your instance. However, you want to put them in a place that will not get bundled into the image itself. The /mnt directory is a great place. You could also put the files into your Elastic Block Store if you've built one.
Bundle the Image
  1. The image I used to spin up the Instance in the first place came with the Amazon Web Services Tools already installed. Otherwise these would have to be installed on the Virtual Machine.
  2. Bundling the instance uses the command ec2-bundle-vol. For more details on the command, you can type ec2-bundle-vol --help. Here is the command line that you'll use to execute the bundling
    1. ec2-bundle-vol -d <location to put image> -k <path to private key .pem> -c <path to public key .pem> -u <AWS Account Number> -r i386 -p <image name> -s 9000
  3. Next you'll need to upload the image to Amazon's place for these things...
    1. ec2-upload-bundle -b <image name> -m <path to .xml manifest> -a <Access Key ID> -s <Secret Access Key ID>
    2. Note: The manifest should be located in the <location to put image> that you specified in the previous step.
  4. Finally, log in to the EC2 Web Console and use the "Register New AMI" button in the AMIs page. The path to your manifest should be <image name>/<image name>.manifest.xml.
Remaining Issues
  1. This process created a Private Image. I don't know how to create a public one.
  2. There seems to be a little bit of lag-time after you register the image. During this time you may see the following issues:
    1. The resulting Image does not show up as "Owned By Me" in the EC2 Web Console.
    2. The metadata in the manifest seems pretty incomplete.
    3. When trying to Launch an Instance from the Image, it does not allow the launch of a small instance.