Creating and Bundling AMIs
Amazon EC2 allows you to set up and configure everything about your instances from your operating
system up to your applications. An Amazon Machine Image (AMI) is simply a packaged-up copy of
your root file system. An AMI contains all the necessary bits to set up and boot an Amazon EC2
instance. Your AMIs are your unit of deployment. You might have just one AMI or you might compose
your system out of several building block AMIs (e.g., webservers, appservers, and databases).
This section details how to build your own AMIs and how to store them in Amazon S3. In addition, it
covers booting existing images, and bundling those (after making any required changes). Re-bundling
modified versions of existing AMIs provides an easy way to build up a range of different machine
images from a pool of existing base images. Amazon EC2 provides base AMIs to get you started.
Amazon EC2
Developer Guide
2
Creating an AMI
There are several techniques for creating an AMI offering a mix of ease of use and detailed
customization levels. The easiest method involves starting from an existing public AMI and modifying it
according to your requirements, as described in the section called “Starting with an Existing AMI” .
Another approach is to build a fresh installation either on a stand-alone machine or on an empty file
system mounted by loopback. This essentially entails building an operating system installation from
scratch and is described in the section called “Creating via a Loopback File” .
Once the installation package has been built to your satisfaction it needs to be bundled and uploaded to
Amazon S3 as described in the section called “Bundling an AMI” .
Starting with an Existing AMI
This is the quickest and easiest of the methods to get a new working AMI. Start with an existing public
AMI or one of your own. You can then modify that as you see fit and subsequently create a new AMI
with the ec2-bundle-vol utility, as decribed later in the section called “Bundling an AMI” .
Select an AMI
The first step is to locate an AMI that contains the packages and services that you require. This can be
one of your own AMIs or one of the public AMIs provided by Amazon EC2. Use ec2-describe-images
to get a list of available AMIs, as is shown below, then select one of the listed AMIs and note its AMI
ID, e.g. ami-61a54008:
PROMPT> ec2-describe-images
IMAGE ami-60a54009 ec2-public-images/base-fc4-apache.manifest 475219833042
available public
IMAGE ami-61a54028 <your-s3-bucket>/image.manifest 495219933132 available
private
IMAGE ami-61a54008 ec2-public-images/getting-started.manifest 475219833042
available public
IMAGE ami-6ea54007 ec2-public-images/base-fc3-mysql.manifest 475219833042
available public
Generate a Keypair
This step is only required if you've selected one of the public AMIs provided by Amazon EC2. A
public/private keypair must be created to ensure that you, and only you, have access to the instances that
you launch.
PROMPT> ec2-create-keypair gsg-keypair
KEYPAIR gsg-keypair
1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC2i/Sgs5BGGd4sunpYQfEkcprgzP9M/hnVJTc1j0nZBeIE2JBuLRSNoqkO7Gw8
nBcdNptaLedzqN8t78jGkX1TPWVAKJTfxRSvU/oViGJaRqIBar0Mpc/wC27kyzHezUNS5+mvONb3
4h/j2EZwDLY75Uxrpka0aN6OkvyIP5gYMQIDAQABAoGAOKH65tBOdjEYSHAh/LeYhGI5wnxWyCAd
C49cLXWix32XvUEircu2kKpiIIsgmT0jvqBuWe/b2noNo0a81z3TzzRYyLvn5J8mUlL6a8nsssQ3
xCHkGM+SE7ZzfBS5WUkbh5Exd3ZXKfCJvJW6auOzJ581JB5yUNbqixWzHuQGGAECQQDwq4LQoyb5
OVSpZwSy+GW/p0yRsqRp89ECNQ+hySGBjkSXBcbt75C+5ebo88/V2V4QOGGa0T0tMsMgKTJ8oukh
AkEAwiyoFM0Zwk0Os3rBZ8PyZoNW5e5SBwrEbLRv4JCaNiQme0ighsDr2bL/nGLI7p13g22+9REM
i/WAmsln50H9EQJASMun6tGepT2pFQBbFIM7y4egCmXdg0rDSoagLtB2eQh+SKvvquKOhp9lg8rT
b5yq7f8PztNBTN2Q1baAVeC04QJAGgN5kS/ZH5rLOWhcuNYbh3hZD/zZqG/c2ONjiaZVwqMdNK8K
MoNuFYBRllX1rWITPNxbFOHv2GBPlm0dKnJAwQJBAOgwjgLY3UpXFX9ZvG4RGEYgfui49Ffz10CH
5sSZpsFYn42E6a2NUJeL4hTzfbGTQ8iCIVjOXFH/9XLTDCNQEPM=
-----END RSA PRIVATE KEY-----
Amazon EC2
Developer Guide
3
Previous Page Next Page