Search code examples
amazon-s3amazon-iamamazon-ami

Import the VM image using the AWS CLI


I'm trying to import my OVA image from my s3 bucket using the AWS CLI. I have

aws ec2 import-image --disk-containers Format=ova,UserBucket="{S3Bucket=arn:aws:s3:::my-vm-rony,"S3Key=windows_7.ova}"

I'm getting the following message:

"An error occurred (InvalidParameter) when calling the ImportImage operation: User does not have access to the S3 object"

My AWS user have the following permission: AmazonS3FullAccess, AdministratorAccess, AWSImportExportFullAccess, VMImportExportRoleForAWSConnector, AWSImportExportReadOnlyAccess, vmimport

I added to my bucket policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Stmt1476979061000",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::109816374014:user/RonyLevi"
            },
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::my-vm-rony",
                "arn:aws:s3:::my-vm-rony/*"
            ]
        }
    ]
}

Solution

  • It should be a bucket name, not ARN:

    aws ec2 import-image --disk-containers Format=ova,UserBucket="{S3Bucket=my-vm-rony,S3Key=windows_7.ova}"