AWS started in year 2006 and has been growing consistently providing over 70 different services with their most popular AWS EC2 (elastic compute) and AWS S3 (simple storage service). AWS has been proven a huge success for companies of all size where they want to either move their dev and qa to AWS, or want to try out building new services without having to spend a vast amount of capital procuring IT hardware or they want to move their production environment to AWS or even legacy applications to AWS without having to go through hardware refresh for legacy apps.

Today, we are going to show you how to move a Hyper-v VM into AWS EC2. In this particular case study. We have a legacy application running on Server 2003 (yeah some still like server 2003 very much), one reason is that it’s pretty challenging to move the legacy app to new OS so we going to stick with Server 2003.

This article covers information related to Hyper-v VM import. So Let’s get started.


You can have a quick look at the pre-requisites for importing Hyper-v VM here. In nutshell here is what you need to take care of.

Only following Microsoft Windows Server editions are supported.

  • Microsoft Windows Server 2003 (Standard, Datacenter, Enterprise) with Service Pack 1 (SP1) or later (32- and 64-bit)
  • Microsoft Windows Server 2003 R2 (Standard, Datacenter, Enterprise) (32- and 64-bit)
  • Microsoft Windows Server 2008 (Standard, Datacenter, Enterprise) (32- and 64-bit)
  • Microsoft Windows Server 2008 R2 (Standard, Datacenter, Enterprise) (64-bit only)
  • Microsoft Windows Server 2012 (Standard, Datacenter) (64-bit only)
  • Microsoft Windows Server 2012 R2 (Standard, Datacenter) (64-bit only)

VM NIC should be configured with Assign address automatically instead of Static IP

VM partition should be MBR. GPT partitions aren’t supported

The disk size more than 1 TB isn’t supported.

Remove Antivirus and disable firewall (alternatively, open MS RDP port 3389 from anywhere for all profiles domain, public, private)

Although not require, however it’s better to uninstall Hyper-v integration services.

  1. Download and Install AWS Command Line Tools & EC2 API Tools

You can download AWS CLI from the following link

Installation of AWS CLI for Windows is quite straight forward, next next finish.

Launch command prompt and type the following command aws configure

You will be presented with series of input. Enter the appropriate values

The profile configuration is store in folder.

You can find more about configure AWS CLI from the following link.

  • Next, we need to install AW EC2 API Tools which will be used to VM import specific tasks.

Go to and download Amazon EC2 API Tools

You can unzip to a location of your choice however for consistency purpose, extract them under C:Program FilesAmazonAWSCLI

  • Next, Install latest version of Java

Now, we will configure the environment variables. You can find more about them here “Configure Environment Variable for AWS EC2 API Tools”

In summary, we will be creating the following User Environment Variables, under System Properties

Create following User Variable

  • EC2_HOME – location of EC2 API Tools Directory
  • JAVA_HOME – – location of Java install Directory
  • AWS_ACCESS_KEY—Your access key ID
  • AWS_SECRET_KEY—Your secret access key

Update Path System Variable

  • %EC2_HOME%bin;
  • %JAVA_HOME%bin;

Once you have done that, you can run the following command to check the System Variables

On CMD prompt, type Dir %EC2_Home%bin and you see the dir listing output.

  1. Create S3 bucket and Assign Service Roles & Policy to the IAM user for VM Import

We need to create an AWS S3 bucket which will be used to hold exported VM.

Login to your AWS console and go to S3.

Create a new bucket. In this case, I have created S3 bucket by the name of vmimportexport20160620

Now that we have S3 bucket created, it’s time to create IAM user and assign policies.

You can either assign the user Admin Policy or create specific policy for granular access.

For creating granular policies, kindly refer to below article. You may require to troubleshoot as It doesn’t always work the first time.

  1. Export Hyper-v VM

  • Launch Hyper-v Manager
  • Shutdown the VM that you want to export
  • Right Click and Export the VM
  1. Import the VM into AWS EC2

On command prompt, issue the following command

ec2-import-instance –region us-west-2 –availability-zone us-west-2b myVM.vhd -f VHD -t m1.medium -a i386 -b vmimport20160620 -o bucketOwnerAccessID -w bucketOwnerSecretKey -p Windows -O Access-Key -W Access-Secret

Now there are few versions of the command on Amazon documentation, which doesn’t seem to work without specific parameters for example –region and –availabilityZone. Another consideration you need to keep in mind is instance type. Only specific instances are supported when importing the vhd file. In this case, I used m1.medium (2 vCPU, 3.75GB RAM). If you choose a non-supported instance, then command will fail. This will import VM into EC2 classic. You can specific subnetID and VPCID to import the instance into EC2 VPC.

Requesting volume size: 299 GB

TaskType IMPORTINSTANCE TaskId import-i-fge3hz0q ExpirationTime 2016-06-29T10:20:28Z Status active StatusMessage Pending InstanceID i-aba46a04

DISKIMAGE DiskImageFormat VHD DiskImageSize 317075112960 VolumeSize 299 AvailabilityZone us-west-2b ApproximateBytesConverted 0 Status active StatusMessage Pending : Downloaded 0

Creating new manifest at vmimport20160620/cf2f67a7-44eb-4d97-a1ba-481117615e99/TmyVM.vhdmanifest.xml

Uploading the manifest file

You can see the upload will begin.

You can run ec2-describe-conversion-tasks ImportTaskID –region to check the status. The command would fail to find the task id if you haven’t specified the region

You can see the DISKIMAGE and IMPORTINSTANCE status and on completion. It can take a while based on the size of the VM to complete the conversion task.

  1. Launch the instance and install AWS EC2Config tools.

  • You can now login to your AWS EC2 console.
  • Under Instance, You will find your new Instance under stopped state.
  • Launch the instance. It will automatically have an EIP and default security group assigned to it.
  • You can take a AMI and change the instance type, if needed and attach additional security groups to manage the access.
  • And don’t forget to install latest EC2Config tools. It’s similar to Hyper-v Integration services.

Hope this helps !!!