Skip to content

Instantly share code, notes, and snippets.

@breenie
Last active December 4, 2019 11:52
Show Gist options
  • Save breenie/f2d78c943e8f36bfca19ee09d7b37e75 to your computer and use it in GitHub Desktop.
Save breenie/f2d78c943e8f36bfca19ee09d7b37e75 to your computer and use it in GitHub Desktop.
Sync AWS S3 buckets across accounts

Sync AWS S3 buckets across accounts

Add the policy.json to the source bucket. Ensure the profile being used has s3:PutObject, s3:GetObject and s3:PutObjectAcl (AWS docs).

Execute:

$ aws s3 sync \
  s3://source \
  s3://target \
  [--acl public-read] \
  [--profile name]
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::666:user/dr.evil"
},
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::bucket/*"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::666:user/dr.evil"
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::bucket"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment