S3 moving files between buckets on different accounts?

前端 未结 5 1087
不知归路
不知归路 2020-12-13 00:35

I\'m doing some work for a client that has 2 separate AWS accounts. We need to move all the files in a bucket on one of their S3 accounts to a new bucket on the 2nd account.

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 01:20

    Ok, figured out an answer. There are likely other ways to do this too, but this is very easy.

    I was able to do this with the s3cmd utility, but can likely be done with similar tools.

    When you configure s3cmd, configure it with your account Access Key and Secret Access Key.

    Log into the S3 web console using the account of the bucket you are transferring to.

    Visit the S3 web console.

    https://console.aws.amazon.com/s3/home
    

    Click on your bucket, then Actions, then Properties.

    At the bottom under the "Permissions" tab click "Add more permissions".

    Set "Grantee" to Everyone
    
    Check "List" and "Upload/Delete"
    
    Save
    

    To transfer, run from your terminal

    s3cmd cp s3://from_account_bucket s3://to_account_bucket --recursive
    

    When the transfer is complete, you should immediately visit the S3 console again and remove the permissions you added for the bucket.

    There is obviously a security problem here. The bucket we're transferring to is open to everyone. The chances of someone finding your bucket name are small, but do exist.

    You can use bucket policies as an alternate way to only open access to specific accounts, but that was too bloody difficult for me to do so I leave that as an exercise to those who need to figure that out.

    Hope this helps.

提交回复
热议问题