Skip to content

Commit efaf9c4

Browse files
authored
Set public access block on created buckets (#730)
1 parent 25a9f5e commit efaf9c4

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

controlpanel/api/aws.py

+18
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,24 @@ def put_bucket_tagging(self, name, tags):
7878
'TagSet': [{'Key': str(k), 'Value': str(v)} for k, v in tags.items()]
7979
})
8080

81+
def put_public_access_block(
82+
self,
83+
bucket_name,
84+
block_public_acls=True,
85+
ignore_public_acls=True,
86+
block_public_policy=True,
87+
restrict_public_buckets=True,
88+
):
89+
self._do('s3', 'put_public_access_block',
90+
Bucket=bucket_name,
91+
PublicAccessBlockConfiguration={
92+
'BlockPublicAcls': block_public_acls,
93+
'IgnorePublicAcls': ignore_public_acls,
94+
'BlockPublicPolicy': block_public_policy,
95+
'RestrictPublicBuckets': restrict_public_buckets,
96+
}
97+
)
98+
8199
def get_inline_policy_document(self, role_name, policy_name):
82100
if not self.enabled:
83101
return None

controlpanel/api/cluster.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def create_bucket(bucket_name, is_data_warehouse=False):
299299
target_prefix=f"{bucket_name}/",
300300
)
301301
aws.put_bucket_encryption(bucket_name)
302-
302+
aws.put_public_access_block(bucket_name)
303303
if is_data_warehouse:
304304
aws.put_bucket_tagging(
305305
bucket_name,

0 commit comments

Comments
 (0)