Importing a VMWare VM into Amazon EC2

I'll show you how to import a VMWare VM from VMWare Workstation into Amazon EC2. At the end I'll also show you how you can cancel a running import.

Running an Import

Install EC2 API Tools

You will need to use the Amazon EC2 API Tools that are available here. You will need to perform some setup to get the tools working. You can follow the Getting Started Guide to get the API tools configured for your environment.

Verify Pre-Requisites

Check the before you get started as there are some limitations in the pre-requisites guide. Specifically for Linux machines the smallest instance size you can start is M3.Medium. You are also limited to certain Linux distros.

Additionally, you'll want to configure the IP address for your machine prior to shutting down the system. For me, this was going into the VPC with a static IP address, so I configured the machine with the address prior to shutting it down.

You will also want to ensure SSH is installed or you won't be able to access your machine.

Create Stream-Optimized Compressed Disk

You will need to convert the virtual disk to a stream-optimized disk using vmware-vdiskmanager which is available in the install path for VMWare Workstation (usually: C:\Program Files (x86)\VMware\VMware Workstation). This is the disk format that is used by the import utility.

The command I ran to execute this was:

vmware-vdiskmanager.exe -r "D:\VirtualMachines\ubuntu-redemine\ubuntu-redmine.vmdk" - t 5 "D:\VirtualMachines\ubuntu-redmine-streamed.vmdk"

Build a script file to run the import

You'll want to review the command line interface options for ec2-import-instance to ensure you configure your import correctly.

For me, I configured my instance to deploy to the VPC where I have other servers running. My options were along the lines of:

ec2-import-instance --region us-east-1 --url --aws-access-key ACCESS_KEY --aws-secret-key MY_SECRET_KEY  --instance-type m3.medium --group sg-0000000 --architecture x86_64 --format VMDK --platform Linux --bucket my-bucket --owner-akid ACCESS_KEY --owner-sak MY_SECRET_KEY --volume-size 20 --availability-zone us-east-1a --subnet subnet-0000000 --private-ip-address "D:\VirtualMachines\ubuntu-redmine.vmdk"

Cancel an Import

To cancel an import you can run the ec2-cancel-conversion-task API method to abort the import.

You can obtain the import task ID by attempting to terminate the instance in the AWS Console. Then you can use it in the API method:

ec2cct --aws-access-key ACCESS_KEY --aws-secret-key MY_SECRET_KEY import-i-ffuvzt3d
comments powered by Disqus