Menu
Amazon Elastic Compute Cloud
User Guide for Linux Instances

Step 4: Importing Your VM into Amazon EC2

After exporting your VM from your virtualization environment, you can import it into Amazon EC2. The import process is the same regardless of the origin of the VM.

Here are some important things to know about your VM instance, as well as some security and storage recommendations:

  • Amazon EC2 automatically assigns a private DHCP IP address to your instance. The DNS name and IP address are available through the ec2-describe-instances command when the instance starts running. To specify the private IP address for your instance, use the --private-ip-address option with the ec2-import-instance command.

    For security reasons, if you import the instance into a VPC, you cannot assign it a public IP address, even though the subnet has auto-assign public IP enabled. However, you may create an Elastic IP address (EIP) and attach it to the imported instance. Alternatively, you can import the VM as an image and then assign a public IP address when you launch it. For more information about importing a VM as an image see Importing a VM into Amazon EC2 as an Image.

  • Your instance has only one Ethernet network interface.

  • To specify a subnet to use when you create the import task, use the --subnet subnet_id option with the ec2-import-instance command; otherwise, your instance will use a public IP address. We recommend that you use a restrictive security group to control access to your instance.

  • We recommend that your Windows instances contain strong passwords for all user accounts. We recommend that your Linux instances use public keys for SSH.

  • For Windows instances, we recommend that you install the latest version of the Amazon Windows EC2Config Service after you import your virtual machine into Amazon EC2.

  • In addition to providing the -o and -w options to specify the Amazon S3 bucket owner and secret key, you must also include the -O and -W options if the AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables are not set.

To import a VM into Amazon EC2

Use ec2-import-instance to create a new import instance task.

The syntax of the command is as follows:

ec2-import-instance disk_image_filename -f file_format -t instance_type -a architecture -b s3_bucket_name -o owner -w secret_key -p platform_name -O your_access_key -W your_secret_key

If the import of the VM is interrupted, you can use the ec2-resume-import command to resume the import from where it stopped. For more information, see Resuming an Upload.

Example (Windows)

The following command creates an import instance task that imports a Windows Server 2008 SP2 (32-bit) VM.

C:\> ec2-import-instance ./WinSvr8-2-32-disk1.vmdk -f VMDK -t m1.small -a i386 -b myawsbucket -o AKIAIOSFODNN7EXAMPLE -w wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY -p Windows -O AKIAI44QH8DHBEXAMPLE -W je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY

This request uses the VMDK file, WinSvr8-2-32-disk1.vmdk, to create the import task. (Note that you can alternatively use VHD or RAW format.) If you do not specify a size for the requesting volume using the -s parameter, a volume size based on the disk image file is used. The output is similar to the following.

Requesting volume size: 25 GB
Disk image format: Stream-optimized VMDK
Converted volume size: 26843545600 bytes (25.00 GiB)
Requested EBS volume size: 26843545600 bytes (25.00 GiB)
TaskType        IMPORTINSTANCE  TaskId  import-i-fhbx6hua       ExpirationTime  2011-09-09T15:03:38+00:00       Status  active  StatusMessage   Pending InstanceID      i-1234567890abcdef0
DISKIMAGE       DiskImageFormat VMDK    DiskImageSize   5070303744      VolumeSize      25      AvailabilityZone        us-east-1c      ApproximateBytesConverted       0       Status  active StatusMessage    Pending
Creating new manifest at testImport/9cba4345-b73e-4469-8106-2756a9f5a077/Win_2008_R1_EE_64.vmdkmanifest.xml
Uploading the manifest file
Uploading 5070303744 bytes across 484 parts
0% |--------------------------------------------------| 100%
   |==================================================|
Done
                

Example (Linux)

The following example creates an import instance task that imports a 64-bit Linux VM.

$ ec2-import-instance rhel6.4-64bit-disk.vhd -f vhd -t m3.xlarge -a x86_64 -b myawsbucket -o AKIAIOSFODNN7EXAMPLE -w wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY -p Linux

This request uses the VHD file, rhel6.4-64bit-disk.vhd, to create the import task. The output is similar to the following.

Requesting volume size: 8 GB
TaskType        IMPORTINSTANCE  TaskId  import-i-ffnzq636       ExpirationTime  2013-12-12T22:55:18Z    Status       active  StatusMessage   Pending InstanceID      i-1234567890abcdef0
DISKIMAGE       DiskImageFormat VHD    DiskImageSize   861055488       VolumeSize      8       AvailabilityZone     us-east-1d      ApproximateBytesConverted       0       Status  active  StatusMessage   Pending
Creating new manifest at myawsbucket/b73bae14-7ec5-4122-8958-4234028e1d9f/rhel6.4-64bit-disk.vhdmanifest.xml
Uploading the manifest file
Uploading 861055488 bytes across 83 parts
0% |--------------------------------------------------| 100%
   |==================================================|
Done

Average speed was 11.054 MBps

The disk image for import-i-ffnzq636 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.