Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: easy way to migrate VM to AWS  (Read 6948 times)

0 Members and 1 Guest are viewing this topic.

aravindm

  • Guest
easy way to migrate VM to AWS
« on: June 10, 2018, 01:13:57 pm »
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: [Select]
aws configure
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: [Select]
aws ec2 create-security-group --group-name uxtechno -- description "UxTechno group"
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: [Select]
aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
Make sure create following “trust-policy.json” file for this under same directory for this role creation.

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

Actual step to migrate vm to AWS

Step 7: In this command we will import this vmdk file on aws using below command:
Code: [Select]
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\"}}]}"
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: [Select]
aws ec2 describe-import-image-tasks --import-task-ids "import-ami-fgmcdnjz"
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.  ;)