awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.22k stars 779 forks source link

How to use two profiles in a single command (advice needed) #184

Closed KunalDongre closed 7 years ago

KunalDongre commented 7 years ago

Hi Guys

I have a requirement wherein I have to copy files from one S3 bucket to another S3 bucket. These S3 buckets have been created on two different accounts. I want to write a script to do the copy process. For this, I created two users on each account and set up profile for each in the credentials file under .aws directory. Now, when I want to copy the files from source to target, I want to do something like the following.

aws --profile source s3 cp s3:// --profile target s3://

i.e use a different profile for source bucket and another profile for target bucket. I understand that I can first execute the aws command only for source bucket and get the files onto my local system and then write another aws command to upload the files to the target bucket using the target profile. However, is there any way by which the above can be accomplished in a single aws command?

Thanks KD

joguSD commented 7 years ago

There's no way to use two profiles in a single command. However, what you can do is use a bucket policy to give the appropriate permissions to the destination profile so that they can copy from the bucket in the source profile.

KunalDongre commented 7 years ago

That is helpful.Thanks!