Reputation: 19
I need to write a lambda function to enable Public access settings for all S3 buckets available in AWS account. As shown in below screenshot, I need lambda functions to enable below two settings Block new public ACLs and uploading public objects Remove public access granted through public ACLs
Upvotes: 0
Views: 1164
Reputation: 269340
You might find it easier to simply change the default settings for this feature.
See: How Do I Edit Public Access Settings for All the S3 Buckets in an AWS Account?
If you do wish to specifically modify the Block settings on a bucket, use put_public_access_block()
:
response = client.put_public_access_block(
Bucket='string',
ContentMD5='string',
PublicAccessBlockConfiguration={
'BlockPublicAcls': True|False,
'IgnorePublicAcls': True|False,
'BlockPublicPolicy': True|False,
'RestrictPublicBuckets': True|False
}
)
Upvotes: 1