How do I use VM Import/Export to create an Amazon EC2 instance based on my on-premises server?

Lesedauer: 3 Minute
0

I want to create a copy of my on-premises server on AWS as an Amazon Elastic Compute Cloud (Amazon EC2) instance using VM Import.

Resolution

You can use the AWS Command Line Interface (AWS CLI) to run a VM Import/Export job. Then, a copy of your server is created as an Amazon Machine Image (AMI) and uploaded to an Amazon Simple Storage Service (Amazon S3) bucket. You can launch the AMI as an EC2 instance.

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

For large-scale migrations, AWS Server Migration Service (SMS) automates the migration process. You can import on-premises virtual machines running on VMware vSphere, Microsoft Hyper-V/SCVMM, and Azure.

Before getting started, do the following:

1.    Follow the guidelines in Required configuration for VM export.

2.    Install the AWS CLI on an on-premises client and configure it with the AWS credentials generated for the VM import user.

3.    Create a new S3 bucket in the same AWS Region where you plan to run your EC2 instance**.**

4.    Create an IAM role named "vmimport" with the trust policy trust-policy.json that allows the VM import service to assume the role.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "vmie.amazonaws.com"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "sts:Externalid": "vmimport"
        }
      }
    }
  ]
}

5.    Attach the following IAM policy named "vmimport" to the IAM role to grant permissions.

Note: Replace disk-image-file-bucket with your S3 bucket name.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetBucketLocation",
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::disk-image-file-bucket",
        "arn:aws:s3:::disk-image-file-bucket/*"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "ec2:ModifySnapshotAttribute",
        "ec2:CopySnapshot",
        "ec2:RegisterImage",
        "ec2:Describe*"
      ],
      "Resource": "*"
    }
  ]
}

6.    Upload the image to the S3 bucket with the tool of your choice.

7.    From the client machine, run the AWS CLI command import-image.

8.    To check the import task status, run the AWS CLI command describe-import-image-tasks.

9.    After the image is imported as an AMI, follow the instructions for Launch an Instance using the old launch instance wizard. Or, follow the instructions for Launch an instance using the new launch instance wizard.


Related information

Import your VM as an image

Creating an IAM user in your AWS account

Programmatic access

Amazon Machine Images (AMI)