Cannot copy between AWS buckets but can copy to local and then to the other bucket

1

I have two buckets in the same account. I have a user that has full access to both buckets and their respective KMS keys.

I cannot copy directly from one bucket to the other, but I can copy from bucket A to my computer and then from my computer to bucket B. Here is an example with the local copy step with account info redacted:

$ aws s3 cp 's3://bucketA/myobject' .
download: s3://bucketA/myobject to ./myobject

$ aws s3 cp ./myobject 's3://bucketB/'
upload: ./myobject to s3://bucketB/myobject

Now here is an example copying directly from bucket to bucket:

$ aws s3 cp 's3://bucketA/myobject' 's3://bucketB/'
copy failed: s3://bucketA/myobject to s3://bucketB/myobject
An error occurred (AccessDenied) when calling the CopyObject operation: Access Denied

I can copy directly from bucketA to bucketB when using an admin account with blanket permissions, so I know that this must be an issue with my user's permissions.

I also know that the issue must be permissions related to copying directly between buckets within the same account as this user. This is because the user can clearly copy from one bucket and upload to another bucket.

Here are the IAM policies attached to this user (with information about the account redacted, of course):

kms for bucketA

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "kms:ReEncrypt*",
                "kms:GetKeyPolicy",
                "kms:GenerateDataKey*",
                "kms:Encrypt",
                "kms:DescribeKey",
                "kms:Decrypt",
                "kms:CreateGrant"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:kms:us-east-1:<account id>:key/<key for bucketA>",
            "Sid": "KMSUsage"
        }
    ]
}

s3 for bucketA

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::<bucketA>",
            "Sid": "ListObjectsInBucket"
        },
        {
            "Action": "s3:*Object",
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::<bucketA>/*",
            "Sid": ""
        }
    ]
}

kms for bucketB

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "kms:ReEncrypt*",
                "kms:GetKeyPolicy",
                "kms:GenerateDataKey*",
                "kms:Encrypt",
                "kms:DescribeKey",
                "kms:Decrypt",
                "kms:CreateGrant"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:kms:us-east-1:<account id>:key/<key for bucketB>",
            "Sid": "KMSUsage"
        }
    ]
}

s3 for bucketB

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::bucketB>",
            "Sid": "ListObjectsInBucket"~
        },
        {
            "Action": "s3:*Object",
            "Effect": "Allow",
            "Resource": "arn:aws:s3:::<bucketB>/*",
            "Sid": ""
        }
    ]
}
1개 답변
0

You will want to set permissions for both the relevant IAM policies and bucket policies.

Here is a Knowledge Center article that explains more about the permissions required: Why can't I copy an object between two Amazon S3 buckets? . Review the section under Confirm these required permissions.

This should help you add the permissions you need in both sets of policies.

Thank you.

profile pictureAWS
Jen_F
답변함 7달 전
profile pictureAWS
전문가
검토됨 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠