1 Answer
- Newest
- Most votes
- Most comments
0
To make your S3 bucket publicly readable, you'll need to:
- First, modify the Block Public Access settings for your bucket:
- Navigate to your bucket in the S3 console
- Click on the "Permissions" tab
- Find "Block public access" and click "Edit"
- Uncheck "Block all public access" (you may need to uncheck all four individual settings)
- Save the changes
- Then add a bucket policy that grants public read access:
- In the "Permissions" tab, go to "Bucket policy"
- Add the following policy (replace "YOUR-BUCKET-NAME" with your actual bucket name):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::YOUR-BUCKET-NAME/*"
]
}
]
}
This policy grants anyone on the internet permission to read any object in your bucket. The /*
at the end of the Resource ARN indicates that the policy applies to all objects within the bucket.
If you get an error when saving the policy, double-check that:
- The bucket name in the policy exactly matches your actual bucket name
- You've properly disabled the Block Public Access settings
- The JSON syntax is correct
Remember that making a bucket public means anyone can access its contents, so ensure you don't store sensitive information there.
Sources
Setting permissions for website access - Amazon Simple Storage Service
frontend s3 bucket access | AWS re:Post
Tutorial: Configuring a static website using a custom domain registered with Route 53 - Amazon Simple Storage Service
Relevant content
- asked 2 years ago
fantastic - thanks for the code
This code works perfectly!