AWS permissions required to copy and encrypt AMI

Viewed 2897

I am trying to copy an AMI from one AWS account to another and encrypt it with a CMK in the target account.

The key policy on the CMK is:

{
  "Version": "2012-10-17",
  "Id": "key-default",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::TARGET-ACCOUNT-NUMBER:root"
      },
      "Action": "kms:*",
      "Resource": "*"
    }
  ]
}

I have created a role in the target account with the following policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kms:ListAliases",
                "kms:GenerateDataKey",
                "kms:DescribeKey",
                "kms:Encrypt",
                "ec2:CopyImage"
            ],
            "Resource": "*"
        }
    ]
}

Also attached to this role is the AmazonEC2ReadOnlyAccess policy.

If I log in to the root account and assume the role in the target account and then try to copy the AMI with my CMK, it fails with Snapshot snap-abc123xyz is in an unexpected state: error. There is no additional information on the snapshot to indicate the root cause.

If I attach the AdministratorAccess policy to the role the AMI copies OK, so it must be a permissions issue.

Can someone provide the list of permissions required to copy an AMI with encryption?

2 Answers

I got the error when I tried to save an AMI from an EC2.

The (only) solution that worked for me was to:

  1. Go to the EC2 dashboard
  2. Right click on the instance, and
  3. Select 'Image and Templates' -> 'Create Image'.

Found this info here

Related