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
- You'll need to locate a few things:
- The private key that identifies your Amazon Web Services account. This is a .pem file.
- The public key that identifies your Amazon Web Services account. This is also a .pem file.
- Your Amazon Web Services Account number.
- Your Amazon Web Services Password and Super-Secret Password.
- 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
- 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.
- 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
- 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
- Next you'll need to upload the image to Amazon's place for these things...
- ec2-upload-bundle -b <image name> -m <path to .xml manifest> -a <Access Key ID> -s <Secret Access Key ID>
- Note: The manifest should be located in the <location to put image> that you specified in the previous step.
- 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
- This process created a Private Image. I don't know how to create a public one.
- There seems to be a little bit of lag-time after you register the image. During this time you may see the following issues:
- The resulting Image does not show up as "Owned By Me" in the EC2 Web Console.
- The metadata in the manifest seems pretty incomplete.
- When trying to Launch an Instance from the Image, it does not allow the launch of a small instance.