devroom.io/content/posts/2010-12-24-public-readable-amazon-s3-bucket-policy.md

34 lines
973 B
Markdown
Raw Normal View History

2015-03-26 11:28:08 +00:00
+++
date = "2010-12-24"
title = "Public Readable Amazon S3 Bucket Policy"
tags = ["amazon", "s3", "cloudfront", "bucket policy"]
slug = "public-readable-amazon-s3-bucket-policy"
+++
Amazon S3 allows you to set per-file permissions to grant read and/or write access. This is nice, but sometimes you just want to share your whole bucket with the world.
Luckily, Amazon features _bucket policies_, which allow you to define permissions for an entire bucket.
~
This example will give _read_ access to _Everyone_ on _all files_ in your bucket.
2017-03-20 15:35:19 +00:00
``` json
{
"Version":"2008-10-17",
"Statement":[{
"Sid":"AllowPublicRead",
"Effect":"Allow",
"Principal": {
"AWS": "*"
},
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::bucket/*"
]
}
]
}
```
2015-03-26 11:28:08 +00:00
**Make sure you replace `bucket` in `arn:aws:s3:::bucket/*` with your bucket name.**
After setting this bucket policy (see 'Bucket -> Properties -> Add Bucket Policy'), all your files will be publicly readable.