Custom Search

Thursday, July 11, 2013

How to Create a new Amazon EC2 AMI from VMware VM or VMDK file

1)
Download vmdk file from ESXi Server
#ovftool vi://root:welcome@192.168.12.154/sm_win3_test2 sm_win3_test2.ovf

2)
Export

export AWS_ACCESS_KEY=XXXXXXXXXXXXXXXX
export AWS_SECRET_KEY=XXXXXXXXXXXXXXXX
export AMS_USER_ID=4471-9218-2508


3)
Convert VMDK file to RAW

#qemu-img convert -O raw sm_win3_test2-disk1.vmdk  output.raw
4)
Bundle this RAW into an AMI using ec2-bundle-image

#ec2-bundle-image -i output.raw -r x86_64 -c cert-XXXXXXXXXXXXXXXX.pem -k pk-XXXXXXXXXXXXXXXX.pem --user $AMS_USER_ID

5)
#ls /tmp
#vim /tmp/output.raw.manifest.xml


6)
Upload the bundle to an S3 bucket.

#ec2-upload-bundle -b import_export -m /tmp/output.raw.manifest.xml -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY

7)
#ec2-describe-images

8)
Register the image

#ec2-register import_export/output.raw.manifest.xml

9)
The AMI should then appear when you request a list of your images.

#ec2-describe-images

Notes
====

1)
How to Upload the bundle to an S3 bucket in the us-west-1 region.
#ec2-upload-bundle -b import-export-us-west-1 -m /tmp/output.raw.manifest.xml -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY --location us-west-1


2)
How to Register the image in us-west-1 region.
#ec2-register import_export/output.raw.manifest.xml --region us-west-1


3)
How to describe images in the us-west-1 region.
#ec2-describe-images --region us-west-1

3 comments:

  1. How to Upload the bundle to an S3 bucket in the us-west-1 region.
    #ec2-upload-bundle -b import-export-us-west-1 -m /tmp/output.raw.manifest.xml -a $AWS_ACCESS_KEY -s $AWS_SECRET_KEY --location us-west-1

    ReplyDelete
  2. Hello,

    Thank you for your post, I would like to know if its possible to deploy the resulting AMI on any kind of instance such as hs1.8xlarge?? or is there a limitation?

    ReplyDelete
  3. Hi
    thank you for good post.

    I am not able to logig on ec2 after deploy my AMI.

    ReplyDelete