Category Archives: Amazon Cloud
Convert VMware vSphere virtual machine to Amazon EC2 instance
Last week I came across an interesting requirement with my client, he wants to convert or export a VMware virtual machine to an Amazon EC2 virtual machine. I have summarized the steps I have done;
There are 2 ways we can do, one is via Amazon EC2 VM Import Connector and other is via Amazon EC2 API Tools. Here we are discussing the command line method.
For the first method you can refer the below link;
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingEC2VMImportConnector.html
You can use the Amazon EC2 VM Import Connector virtual appliance (vApp), a plug-in for VMware vCenter, to import virtual machines from your VMware vSphere infrastructure to Amazon EC2. The Connector is a virtual appliance that works with VMware vCenter Server only. It provides an easy-to-use interface, enhancing your existing management tools to work with the Amazon EC2 VM Import Connector.
Note
You cannot use the Connector to import Citrix Xen or Microsoft Hyper-V virtual machines to Amazon EC2. Instead, use the command line tools to import your Citrix and Hyper-V virtual machines to Amazon EC2. You can also choose to use the command line tools to import your VMware VMs.
For the command line method refer the below;
You need to install the Amazon EC2 Command Line Interface Tools or called as Amazon EC2 API Tools, in Windows or Linux operating system.
1 – Download and Configuring the Amazon EC2 API Tools as per the below links;
http://aws.amazon.com/developertools/351
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/setting-up-your-tools.html
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/prerequisites.html
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/InstallEC2CommandLineTools.html
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SettingUp_CommandLine.html
2 – Export the required VMware VM in OVF format as per the link
3 – Now import the OVF appliance in to the EC2 by command line as per the link
https://forums.aws.amazon.com/thread.jspa?messageID=214948
Detailed steps;
1, First set the variables in the user profiles and appened the system path
JAVA_HOME = C:\Program Files\Java\jre7\
EC2_HOME = C:\ec2-api-tools
EC2_PRIVATE_KEY C:\ec2-api-tools\pk-DAO4BK4FRAF52NVUD6NU6VVHK772FBE3.pem
EC2_CERT C:\ec2-api-tools\cert-DAO4BK4FRAF52NVUD6NU6VVHK772FBE3.pem
append ;C:\ec2-api-tools\bin to windows System PATH variable
If the above variables are set correctly we get the below when we execute the command ec2-describe-regions
C:\Documents and Settings\admin.gopinath.k>ec2-describe-regions
REGION eu-west-1 ec2.eu-west-1.amazonaws.com
REGION sa-east-1 ec2.sa-east-1.amazonaws.com
REGION us-east-1 ec2.us-east-1.amazonaws.com
REGION ap-northeast-1 ec2.ap-northeast-1.amazonaws.com
REGION us-west-2 ec2.us-west-2.amazonaws.com
REGION us-west-1 ec2.us-west-1.amazonaws.com
REGION ap-southeast-1 ec2.ap-southeast-1.amazonaws.com
2, i have exported a 64 bit RHEL6 vm called Nessus-Proffessional and stored in the location \\weststorage10\d$\Storage\OS\VMware\templates\Nessus-Proffessional
3, Now for importing we need to use the command “ec2-import-instance” syntax of the command is
ec2-import-instance DISK_IMAGE_FILENAME -t INSTANCETYPE -f FORMAT -a ARCHITECTURE-SYSTEM -b S3_BUCKET_NAME -o OWNER -w SECRETKEY
for 32 bit vms we need to use the below
ec2-import-instance C:\Nessus-Proffessional\Nessus-Proffessional-disk1.vmdk -f VMDK -t m1.small -a i386
-b API-test-bucket -o AKIAISRI3LTKFRR2TYEQ -w vQxFp44FdDGzTeE7qprEvwvNuhYxwg+Nt7iIY1d+
for 64 bit vms we need to use the below
ec2-import-instance C:\Nessus-Proffessional\Nessus-Proffessional-disk1.vmdk -f VMDK -t m1.small -a x86_64 -b API-test-bucket -o AKIAISRI3LTKFRR2TYEQ -w vQxFp44FdDGzTeE7qprEvwvNuhYxwg+Nt7iIY1d+
4, The result we got is below;
C:\Documents and Settings\admin.gopinath.k>ec2-import-instance C:\Nessus-Proffessional\Nessus-Proffessional-disk1.vmdk -f VMDK -t m1.large -a x86_64 -b API-test -bucket -o AKIAISRI3LTKFRR2TYEQ -w vQxFp44FdDGzTeE7qprEvwvNuhYxwg+Nt7iIY1d+
Requesting volume size: 30 GB
Disk image format: Stream-optimized VMDK
Converted volume size: 32212254720 bytes (30.00 GiB)
Requested EBS volume size: 32212254720 bytes (30.00 GiB)
TaskType IMPORTINSTANCE TaskId import-i-fga6rr6l ExpirationTime
2012-01-10T12:46:31+00:00 Status active StatusMessage Pending Instance ID i-a683e7c4
DISKIMAGE DiskImageFormat VMDK DiskImageSize 3383129600 VolumeSize 30 AvailabilityZone us-east-1d ApproximateBytesConverted 0 Status active StatusMessage Pending
Creating new manifest at API-test-bucket/a99d465a-86db-499d-8c19-77fb6baa27a6/Nessus-Proffessional-disk1.vmdkmanifest.xml
Uploading the manifest file
Uploading 3383129600 bytes across 323 parts
0% |————————————————–| 100%
|==================================================|
Done
Average speed was 2.216 MBps
The disk image for import-i-fga6rr6l has been uploaded to Amazon S3 where it is being converted into an EC2 instance. You may monitor the progress of this task by running ec2-describe-conversion-tasks. When
the task is completed, you may use ec2-delete-disk-image to remove the image from S3.
5, Current status of the entire process
C:\Documents and Settings\admin.gopinath.k>ec2-describe-conversion-tasks
TaskType IMPORTINSTANCE TaskId import-i-fga6rr6l ExpirationTime 2012-01-10T12:46:31+00:00 Status active StatusMessage PendingInstance ID i-a683e7c4
DISKIMAGE DiskImageFormat VMDK DiskImageSize 3383129600 VolumeSize 30 AvailabilityZone us-east-1d ApproximateBytesConverted 2748806848 Status active StatusMessage Pending
C:\Documents and Settings\admin.gopinath.k>ec2-describe-conversion-tasks
TaskType IMPORTINSTANCE TaskId import-i-fga6rr6l ExpirationTime 2012-01-10T12:46:31+00:00 Status cancelling StatusMessage ClientError: No windows directory found. InstanceID i-a683e7c4
DISKIMAGE DiskImageFormat VMDK DiskImageSize 3383129600 VolumeId vol-97b4fbfa VolumeSize 30 AvailabilityZone us-east-1d ApproximateBytesConverted
3383129600 Status completed