From 09014e92a2a3b21cbf775d2106de53ac5b6c8e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 30 Aug 2018 14:43:28 -0400 Subject: [PATCH] add script for making all files in a bucket public --- s3utils/make_public.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 s3utils/make_public.py diff --git a/s3utils/make_public.py b/s3utils/make_public.py new file mode 100644 index 0000000..9f6acba --- /dev/null +++ b/s3utils/make_public.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +import os +import boto3 +import botocore + +bucket_name = 'status-im' + +session = boto3.session.Session() + +s3 = boto3.resource( + 's3', + region_name='ams3', + endpoint_url='https://ams3.digitaloceanspaces.com', + aws_access_key_id=os.environ['DO_ID'], + aws_secret_access_key=os.environ['DO_SECRET'] +) + +bucket = s3.Bucket(bucket_name) + +for obj in bucket.objects.all(): + if obj.key == 'index.html': + continue + rval = obj.Acl().put(ACL='public-read') + result = rval['ResponseMetadata']['HTTPStatusCode'] + print('{:<30} - {}'.format(obj.key, result))