How To Make S3 Bucket Public In Python
I have an already created bucket in amazon s3. I want to make its content publicly available without any authentication. I have tried from documents of boto To set a canned ACL fo
Solution 1:
You will need to create a Bucket Policy, which defines permissions on the bucket as a whole.
See 'Bucket Policy' in: Managing Access to S3 Resources (Access Policy Options)
You can do this via boto
in Python with put_bucket_policy()
:
put_bucket_policy(**kwargs)
Replaces a policy on a bucket. If the bucket already has a policy, the one in this request completely replaces it.
Request Syntax
response = client.put_bucket_policy(Bucket='string', Policy='string')
See Bucket Policy Examples to find a suitable policy.
Here is a policy that makes the whole bucket publicly readable (just insert your own bucket name):
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"]
}
]
}
Post a Comment for "How To Make S3 Bucket Public In Python"