Linux > Virtualization

easy way to migrate VM to AWS

(1/1)

aravindm:
There are couple of steps you need to follow to migrate vm to AWS. However I will suggest you to go through these pre-requisites before you migrate vm to AWS.


Step 1:  Install AWS Command line interface. Please follow this article to perform the installation.

Step 2: Create user in AWS with programmatic access. For this login to AWS console and go to IAM under  “Security, Identity & Compliance” service. Click on User on the left pane.  Then click on Add user button to create AWS user. In the next window use suitable user name and select “Programmatic access” option. Click on Next:Permissions button. Then select “Attach existing policies directly” options and select “AdministratorAccess” policy under policies options. Click on “Next:Review” button to review the setup. At the end select “Create user” option to create AWS user. In the next window you will see “Access key ID” and “Secret access key” which are required for configuration. You can also download it as CSV file.



Step 3: Configure AWS user in command line inter face. Follow below commands to configure AWS CLI.

--- Code: ---aws configure
--- End code ---

System will ask you about Access Key ID and your Secret Access Key. Also it will ask you about default region. Kindly input the keys captured in previous step.

To confirm the configuration, create sample security group using below command:

--- Code: ---aws ec2 create-security-group --group-name uxtechno -- description "UxTechno group"
--- End code ---

If you got new security group created then, you have successfully configured aws cli with user created.

Take vm backup using ovf method and upload to S3

Step 4: Take the ovf backup of the vm. That’s pretty straightforward. After backup is complete you will get one OVF file and vmdk file.

Step 5: In the next step you need to create S3 bucket in AWS and upload this vmdk file inside this bucket.

Please note that, we have uploaded vcf file “rhel-disk1.vmdk” inside the bucket called “aws-import-dir” same has been used during the step  7.

 Step 6: Create IAM role with name vmimport which will have access to this bucket.

--- Code: ---aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
--- End code ---

Make sure create following “trust-policy.json” file for this under same directory for this role creation.

    trust-policy.json file contents:

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

Actual step to migrate vm to AWS

Step 7: In this command we will import this vmdk file on aws using below command:

--- Code: ---aws ec2 import-image --cli-input-json "{ \"Description\": \"my linux image\",\"DiskContainers\": [ {\"Description\": \"my linux image\",\"User Bucket\":{ \"S3Bucket\":\"aws-import-dir\" ,\"S3Key\" :\"rhel-disk1.vmdk\"}}]}"
--- End code ---

Please make sure you note down the import id which is “import-ami-fgmcdnjz” in this case. This import can be used to check the status of import activity and can be checked with below command:

--- Code: ---aws ec2 describe-import-image-tasks --import-task-ids "import-ami-fgmcdnjz"
--- End code ---

After this you can able to snapshot backup in AWS console within few seconds as below:



Then after few minutes you can able to check the AMI image successfully created in console as below:



Once the status becomes available you can launch in AWS.  ;)

Navigation

[0] Message Index

Go to full version