Labels

Tuesday, February 16, 2010

Bundle up your customized server

Very obviously this makes a lot of sense! I agree that setting up a system from scratch is a lot of fun but you don't wanna do it every time you want to add your numbers !

Once you customize your environment, install your applications its best to make an image and save it for future instantiations.

We have two choices (as of this writing) to create an image: Store image in S3 or Store image in EBS.
The pricing model of Amazon still confuses me a bit. Although EBS has a lot of advantages over S3, it has to be costlier too !

Anyhow, I will describe how you can create images and store on both these services.

Create Image and Store in S3:


1. Launch the Instance : Duh !

2. Customize it to the needs : You better do this if you want to make any sense of this process :-)

3. Create a Bucket using S3Fox : You definitely should have S3Fox installed ! The whole purpose of this blog is to make the job easy using the various tools out there. Creating a Bucket beforehand is not really required. The bucket will be created if it doesn't exist in the future steps. Although this is a better way.

5. Upload the Private and Certificate keys to the /mnt folder on your instance. Use SCP for this.
(Aha .. this is why we installed cygwin...all little tools under one roof )

scp -i #keypair# #private-key# #cert# #instance-address#:/mnt

This should look like

scp -i gsg_keypair.pem pk-MF6AQ2TDUODJIZEGZ5Y7ZGNKNPEIPU4M.pem cert-MF6AQ2TDUODJIZEGZ5Y7ZGNKNPEIPU4M.pem root@ec2-37-212-46-94.compute-1.amazonaws.com:/mnt



6. Now Bundle up your image into a temporary file on your instance itself. (in the /mnt folder). The following command gets it going.

ec2-bundle-vol -d /mnt -k /mnt/#private-key.pem# -c /mnt/#cert.pem# -u #amazon-account-number# -r i386 -p #image-name#

Note that the Amazon Account number is the 12 digit number you'll find when you log into aws.amazon.com NOT your amazon id !


This command should look like

ec2-bundle-vol -d /mnt -k /mnt/pk-MF6AQ2TDUODJIZEGZ5Y7ZGNKNPEIPU4M.pem -c /mnt/cert-MF6AQ2TDUODJIZEGZ5Y7ZGNKNPEIPU4M.pem -u 111122223333 -r i386 -p imgname



7. Now once the image has bundled up. You would cut it into small pieces and upload it to your bucket !
The following command should take care of that :

ec2-upload-bundle -b #bucket-name# -m /mnt/#image-name#.manifest.xml -a #access-key# -s #secret-access-key#

This should look like : 

ec2-upload-bundle -b imgname -m /mnt/imgname.manifest.xml -a Q2T3RAKIAJJC6WLIJA2A -s 3La9QKLjk9AkjfgJJC6W/sMYrphJC8Tk9A


8. The last step is to register the image so that you can use it . Enter this command in cygwin on your LOCAL terminal NOT on the instance.

ec2-register #bucket# / #image-name#.manifest.xml

This should look like

ec2-register imgname/imgname.manifest.xml

No comments:

Post a Comment