Creating a VM Import Service Role

  1. In the AWS web interface navigate to AWS dashboard > Identity & Access Management.
  2. Check your account permission by navigating to Users > select your Username > Permissions. Your account should have the permission - IAMFullAccess.

    Account Permission

  3. Create a JSON file called trust-policy.json using the following commands:
    {   "Version":"2012-10-17",
       "Statement":[
          {
             "Sid":"",
             "Effect":"Allow",
             "Principal":{            "Service":"vmie.amazonaws.com"
             },
             "Action":"sts:AssumeRole",
             "Condition":{
                "StringEquals":{
                   "sts:ExternalId":"vmimport"
                }
             }
          }
       ]
    }
  4. Use the following command to create a role. Specify the name as vmimport and give the option VM Import/Export access.
    # aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json
  5. Create a policy for the service role by creating a JSON file called role-policy.json using the following commands. Replace the bucket name with the storage bucket name that you created.
    {
       "Version":"2012-10-17",
       "Statement":[
          {
             "Effect":"Allow",
             "Action":[
                "s3:ListBucket",
                "s3:GetBucketLocation"
             ],
             "Resource":[
                "arn:aws:s3:::<bucket-name>"
             ]
          },
          {
             "Effect":"Allow",
             "Action":[
                "s3:GetObject"
             ],
             "Resource":[
                "arn:aws:s3:::<bucket-name>/*"
             ]
          }
  6. Run the following command to attach the policy to the service role created. # aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json