How can I set a bucket in Amazon S3 so all the files are publicly read-only by default?
Users can control the accessibility and privacy of their S3 buckets in bucket policy. It is recommended that AWS S3 buckets should not be publicly accessible to other users in AWS. Publicly accessible S3 bucket means that other AWS users can access your data stored in the bucket which can lead to misuse of the data.
Steps to allow public access to private AWS S3 bucket files: Click on the private S3 bucket with the object that you want to make public. Click on the Permissions tab. Click Edit on the Block public access section. Click on the Block all public access to uncheck and disable the options.
Object ACLs S3 objects do inherit parent bucket's permissions, but they can also have their own ACL that can bypass such permissions. You can make single objects public while the bucket ACL states it's private, although to access that object one must know the full path to it.
You can set a bucket policy as detailed in this blog post:
http://ariejan.net/2010/12/24/public-readable-amazon-s3-bucket-policy/
As per @robbyt's suggestion, create a bucket policy with the following JSON:
{ "Version": "2008-10-17", "Statement": [{ "Sid": "AllowPublicRead", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": ["s3:GetObject"], "Resource": ["arn:aws:s3:::bucket/*" ] }] }
Important: replace bucket
in the Resource
line with the name of your bucket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With