health /
Bucket policies - Boto3 1.34.87 documentation
import json# Create a bucket policybucket_name = 'BUCKET_NAME'bucket_policy = { 'Version': '2012-10-17', 'Statement': [{ 'Sid': 'AddPerm', 'Effect': 'Allow', 'Principal': '*', 'Action': ['s3:GetObject'], 'Resource': f'arn:aws:s3:::{bucket_name}/*' }]}# Convert the policy from JSON dict to stringbucket_policy = json.dumps(bucket_policy)# Set the new policys3 = boto3.client('s3')s3.put_bucket_policy(Bucket=bucket_name, Policy=bucket_policy)