Importing Virtual Machines (VM) to AWS cloud as AMI

Note: You can perform these via the CLI but in our case we used the AWS Web Console
Verify if the VMIMPORT Role is currently created on your AWS roles… if not you must have to create this role. [For us it has been created].

Navigate to Roles
– Create Roles
– Search for the VMIMPORT Role and follow the steps: Very straight forward!
Steps 3: Click on the VMIMPORT ROLE created
-Navigate to the Trust relationship and
-Click on edit trust relationship

Ensure you have your Trust relationship this way

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

Now from the CLI, run the following command below.
Note: The right permission (policy must attached to the VMIMPORT role or else it will fail and complain of not having sufficient permission to continue.

Modify the syntax below and replace with your ova file and your s3 bucket name shown below.

aws ec2 import-image --cli-input-json "{  \"Description\": \"Dxxxx.ova\", \"DiskContainers\": [ { \"Description\": \"Dxxxxxx.ova\", \"UserBucket\": { \"S3Bucket\": \"cx-texa-eu-central-1\", \"S3Key\" : \"Dxxxxova\" } } ]}"

When successfully imported, ‘ success’ is display