Arpith Siromoney 💬

Copying an S3 Bucket

This is how you copy the contents of an S3 bucket to a bucket in another AWS account.

Install the AWS CLI

If you’re on OS X like me, installing the AWS CLI is straightforward:

$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
$ unzip awscli-bundle.zip
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Open a new Terminal window or tab, and you can now use it.

Store credentials

Create a file called credentials in ~/.aws that looks like:

[default]
aws_access_key_id=YOUR_ACCESS_KEY_ID
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY

Grant Permissions

The account that owns the destination S3 bucket needs List and View permissions for the source S3 bucket. If your case is like mine, and your bucket only contains public content anyway, you can just add these permissions for everyone. Otherwise follow these instructions!

Copy Recursively

Now all that’s left is to use the AWS CLI to recursively copy the objects in the source bucket.

aws s3 cp s3://sourceBucketName/ s3://destinationBucketName/ --recursive

That’s about it! Doing something interesting on AWS? Let’s talk!