Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
Created June 9, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthuralvim/fcc406c6cc8d89c482434afc8e8d8d7a to your computer and use it in GitHub Desktop.
Save arthuralvim/fcc406c6cc8d89c482434afc8e8d8d7a to your computer and use it in GitHub Desktop.
Move S3 files to another bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAll",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::111122223333:user/iam_role"
]
},
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::from_bucket",
"arn:aws:s3:::from_bucket/*"
]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAll",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::111122223333:user/iam_role"
]
},
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::from_bucket",
"arn:aws:s3:::from_bucket/*"
]
}
]
}
1. CREATE YOUR IAM ROLE, GET AWS KEYS.
2. aws configure
3. aws s3 ls s3://from_bucket | wc -l
4. aws s3 ls s3://to_bucket | wc -l
5. aws s3 sync s3://from_bucket/ s3://to_bucket/ --recursive
# all credits to http://blog.vizuri.com/how-to-copy/move-objects-from-one-s3-bucket-to-another-between-aws-accounts
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::from_bucket/*",
"arn:aws:s3:::to_bucket/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::from_bucket",
"arn:aws:s3:::to_bucket"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment