Created
December 8, 2017 14:51
-
-
Save tomislacker/047f32cdd925b60bd8e6196e6290272c to your computer and use it in GitHub Desktop.
Fix S3 ACL for public reads after `s3 sync s3://src s3://dst`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import boto3 | |
import sys | |
s3 = boto3.resource('s3') | |
try: | |
bucket = s3.Bucket(sys.argv[1]) | |
except IndexError: | |
print("ERROR: No bucket name provided") | |
sys.exit(1) | |
for o in bucket.objects.all(): | |
try: | |
print(o.key) | |
except Exception: | |
print("non-ascii key") | |
o.Acl().put( | |
ACL='public-read', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment