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

前端 未结 2 460
予麋鹿
予麋鹿 2021-01-18 20:50

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

aws s3 cp --profile source_profile s3://source_bucket/file         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 21:27

    No, you can't use multiple profiles in one AWS CLI command. Possible solutions:

    1) Download files to local disk, then upload them to the target bucket with a separate command.

    2) Allow first account access to the target bucket. For this, you will have to create a cross-account role in the source account and assign it the appropriate permissions in the target account. That way you will be using one role/one profile, but this role will be granted permissions in the second account. See https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_cross-account-with-roles.html

提交回复
热议问题