Bundling A Custom AMI


You will see a slew of public images (including some of our own), and the list is actualy quite daunting. This is actually a very important step since this will be the foundation on which you build you AMI. We use (exclusively) the Alestic Debian AMIs (32-bit or 64-bit depending on the application). More information about what Alestic can be here. Search through the list, and find whichever base image you want to work with. If you are starting with Ubuntu or Debian, I really insist on using the Alestic images - they are frequently updated and are highly optimized for EC2.

Now that you’ve got your base AMI in hand, lets get to getting.

To begin, spawn your instance (I chose a Debian base AMI):

ec2-run-instances ami-67fe190e

Or spawn it with Elasticfox

Notice that when using a public AMI, you must spawn it using a keypair so you can access it. To read more about keypairs, check out our other tutorial. Once the instance has become available, ssh into it (Windows users check our article on using Putty and EC2).


ssh root@ec2-72-44-61-6.compute-1.amazonaws.com -i ~/.ssh/id-cloud-carpenters

Once logged in, make like a sysadmin and get to apting - or rather, apt to getting. You get the idea.

apt-get update
apt-get upgrade
apt-get install git-core apache2-mpm-worker libapache2-mod-python

Now that your instance is awesome, you need to bundle it. The Alestic AMIs come with the AMI tools already installed so there’s no need to download them. In order to bundle a image, you will need your private key and certificate issued by Amazon. You can find them on http://aws.amazon.com under “Your Account” and then “Access Identifiers”. When you are first prompted to generate a certificate file, you should recieve the cert-yourcert.pem and pk-yourpk.pem files. Again, this tutorial is assuming you have a basic knowledge of EC2 which includes this account identification stuff. If you’re having trouble with this, try the unofficial IRC channel (##aws), or read Amazon’s getting started guide. Once you have the private key and certificate files on the instance, start the bundle.


ec2-bundle-vol -c /root/.ec2/cert-yourcert.pem -k /root/.ec2/pk-yourpk.pem -d /mnt -u 0123456678901 -e /root/.ec2

A couple of notes about that command. Notice the pk and cert are in a directory under root called “.ec2”. I put them in their own directory so that I can explicitly exclude that directory from the bundle, because you probably don’t want you cert and private key on the newly created image (especially if you make it public). The “-u” is your 12 digit account number sans dashes from “Your Account” on http://aws.amazon.com, and “-e” is a comma-delimited list of directories you want excluded from the bundle.

The bundle shouldn’t take all that long (unless you installed a lot of stuff, or have some data files or something). It usually takes less than 5 minutes for our images to bundle (we rebundle often). After the bundling is complete, simply upload it to your S3 account.

ec2-upload-bundle -b bucket-for-new-image -m /mnt/image.manifest.xml-a yourawsaccesskeyid -s yourawssecretkey

The AWS Access Key Id and Secret Key can be found on your “Access Identifiers” page on Amazon’s website. I like to give my images meaningful names unlike “cloudcarpenters-the-best-image-ever” or “cloudcarpenters-my-ami-brings-all-the-boys-to-the-yard”.

The final step before testing you delicious new AMI is registering the manifesto manifest. This can be done with Elasticfox or with the EC2-API-tools.

ec2-register

Personally, I’ve found Elasticfox to be somewhat flaky in this department, so I typically will use the command line tools. Note: If you register an existing image manifest, it will override any previous AMI that used that manifest. Sometimes this is the desired functionality, sometimes not. If you need to do versioning with your images I would recommend a naming scheme like: my-lamp-image-0.1, my-lamp-image-0.2, etc.

Once the image is registered, launch it log in and make sure you didn’t leave anything important lying around - you know, like you certificate/private keyxt, your SSN, incriminating photos, etc.

You now have you’re very own AMI!

 

You will see a slew of public images (including some of our own), and the list is actualy quite daunting. This is actually a very important step since this will be the foundation on which you build you AMI. We use (exclusively) the Alestic Debian AMIs (32-bit or 64-bit depending on the application). More information about what Alestic can be here. Search through the list, and find whichever base image you want to work with. If you are starting with Ubuntu or Debian, I really insist on using the Alestic images - they are frequently updated and are highly optimized for EC2.

Now that you’ve got your base AMI in hand, lets get to getting.

To begin, spawn your instance (I chose a Debian base AMI):

ec2-run-instances ami-67fe190e

Or spawn it with Elasticfox

Notice that when using a public AMI, you must spawn it using a keypair so you can access it. To read more about keypairs, check out our other tutorial. Once the instance has become available, ssh into it (Windows users check our article on using Putty and EC2).


ssh root@ec2-72-44-61-6.compute-1.amazonaws.com -i ~/.ssh/id-cloud-carpenters

Once logged in, make like a sysadmin and get to apting - or rather, apt to getting. You get the idea.

apt-get update
apt-get upgrade
apt-get install git-core apache2-mpm-worker libapache2-mod-python

Now that your instance is awesome, you need to bundle it. The Alestic AMIs come with the AMI tools already installed so there’s no need to download them. In order to bundle a image, you will need your private key and certificate issued by Amazon. You can find them on http://aws.amazon.com under “Your Account” and then “Access Identifiers”. When you are first prompted to generate a certificate file, you should recieve the cert-yourcert.pem and pk-yourpk.pem files. Again, this tutorial is assuming you have a basic knowledge of EC2 which includes this account identification stuff. If you’re having trouble with this, try the unofficial IRC channel (##aws), or read Amazon’s getting started guide. Once you have the private key and certificate files on the instance, start the bundle.


ec2-bundle-vol -c /root/.ec2/cert-yourcert.pem -k /root/.ec2/pk-yourpk.pem -d /mnt -u 0123456678901 -e /root/.ec2

A couple of notes about that command. Notice the pk and cert are in a directory under root called “.ec2”. I put them in their own directory so that I can explicitly exclude that directory from the bundle, because you probably don’t want you cert and private key on the newly created image (especially if you make it public). The “-u” is your 12 digit account number sans dashes from “Your Account” on http://aws.amazon.com, and “-e” is a comma-delimited list of directories you want excluded from the bundle.

The bundle shouldn’t take all that long (unless you installed a lot of stuff, or have some data files or something). It usually takes less than 5 minutes for our images to bundle (we rebundle often). After the bundling is complete, simply upload it to your S3 account.

ec2-upload-bundle -b bucket-for-new-image -m /mnt/image.manifest.xml -a yourawsaccesskeyid -s yourawssecretkey

The AWS Access Key Id and Secret Key can be found on your “Access Identifiers” page on Amazon’s website. I like to give my images meaningful names unlike “cloudcarpenters-the-best-image-ever” or “cloudcarpenters-my-ami-brings-all-the-boys-to-the-yard”.

The final step before testing you delicious new AMI is registering the manifesto manifest. This can be done with Elasticfox or with the EC2-API-tools.

ec2-register

Personally, I’ve found Elasticfox to be somewhat flaky in this department, so I typically will use the command line tools. Note: If you register an existing image manifest, it will override any previous AMI that used that manifest. Sometimes this is the desired functionality, sometimes not. If you need to do versioning with your images I would recommend a naming scheme like: my-lamp-image-0.1, my-lamp-image-0.2, etc.

Once the image is registered, launch it log in and make sure you didn’t leave anything important lying around - you know, like you certificate/private keyxt, your SSN, incriminating photos, etc.

You now have you’re very own AMI!

 

david on 06/04/2009 | 872 Comments
oanlfbsecoy
on 11/13/2009

OdpL0f ezapqbcfonfe, kublqanfygrz, [link=http://zjichkcdabwh.com/]zjichkcdabwh[/link], http://lisuayjlpzge.com/

Cezar
on 11/23/2009

cialis 148095 accutane uphrxs

zehxjwjd
on 12/12/2009

seF7jG qmoesxcmyurc, xqumpsfbrbqj, [link=http://cvexhxvirzuy.com/]cvexhxvirzuy[/link], http://bpeurbuvaysj.com/

nvyhtwtic
on 12/15/2009

Tl7opt jlxmkskgtztu, jpqmuuhihhkg, [link=http://ighxdhzgdyzx.com/]ighxdhzgdyzx[/link], http://zdwpoqjbbxqm.com/

arialfett
on 12/20/2009

valium wnkfpj tramadol qohvoq xanax ohq

firstparagraph
on 12/20/2009

valium xajo cialis 89742

New Comment


Name
Email

Notify me of follow-up comments?

Categories

Calendar

July 2010
S
M
T
W
T
F
S
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Copyright ©2009. Loot whatever you like as long you're not a Rogue.