Skip to content

Commit

Permalink
delete_public_access_block for bucket if public (#25663)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergey Chvalyuk <grubberr@gmail.com>
  • Loading branch information
grubberr authored Apr 28, 2023
1 parent c6b8181 commit 67f047c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def cloud_files(self, cloud_bucket_name: str, credentials: Mapping, files_to_upl
try:
self.s3_client.head_bucket(Bucket=bucket_name)
except ClientError:
acl = "private" if private else "public-read"
self.s3_client.create_bucket(ACL=acl, Bucket=bucket_name, CreateBucketConfiguration=location)
if private:
self.s3_client.create_bucket(Bucket=bucket_name, CreateBucketConfiguration=location)
else:
self.s3_client.create_bucket(Bucket=bucket_name, CreateBucketConfiguration=location, ObjectOwnership='ObjectWriter')
self.s3_client.delete_public_access_block(Bucket=bucket_name)
self.s3_client.put_bucket_acl(Bucket=bucket_name, ACL='public-read')

# wait here until the bucket is ready
ready = False
Expand Down

0 comments on commit 67f047c

Please sign in to comment.