How can we copy s3 files between buckets of different account/credentials using s3 cp and different profiles?

Question:

I created two profiles (one for source and one for target bucket) and using below command to copy:

But it throws below error.

Looks like we can’t use multiple profiles with aws commands.

Answer:

The simplest method is to grant permissions via a bucket policy.

Say you have:

  • Account-A with IAM User-A
  • Account-B with Bucket-B

Add a bucket policy on Bucket-B:

Then just copy the files as User-A.

See also: aws sync between S3 buckets on different AWS accounts

Leave a Reply