Creating an Amazon EC2 AMI from an existing image seems like a challenging process however, it is actually fairly simple. Before looking at the steps to create the image, first have the following AWS information/files handy:
- Access key
- Secret Key
- Account Number
- Private key (e.g., pk-37BKCPZ2AVHVSYBK2WZXUQ9D4GQZEB4Q.pem)
- Certificate (e.g., cert-38BKCPZ1BOHVSYBK4WZXUQ4D4GQZEB2Q.pem)
Now you are ready to create your image file. First create a directory to store this image in.
The actual AMI bundle is created by running:
ec2-bundle-vol -d /mnt/ami -k YOUR_PRIVATE_KEY -c YOUR_CERTIFICATE -u YOUR_ACCOUNT_NUMBER
note: The account number should not contain any dashes (‘-’).
Creating the bundle takes a few minutes. After the bundle has been created, it is time to upload it to S3. This is done by running:
ec2-upload-bundle -b YOUR_BUNDLE_NAME -m /mnt/ami/image.manifest.xml -a YOUR_ACCESS_KEY -s YOUR_SECRET_KEY
This walks through the files generated by the bundle command and inserts them into S3.
After your files have been uploaded, it is time to register the AMI using the following command:
The result of running this command is your AMI id.
Finally, your AMI has been created, uploaded and registered and you are able to launch a new instance of your AMI.