- Newest
- Most votes
- Most comments
To make just one file in your S3 bucket publicly viewable, you'll need to follow these steps:
- First, you need to modify the Block Public Access settings for your bucket:
- Go to the S3 console and navigate to your bucket
- Click on the "Permissions" tab
- Find the "Block public access" section and click "Edit"
- Uncheck "Block all public access" (you may need to uncheck all four individual settings)
- Save the changes
- Then, create a bucket policy that grants public read access only to the specific object:
- In the "Permissions" tab, go to "Bucket policy"
- Add a policy similar to this (replace the bucket and object path):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForSingleObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/path/to/your/specific/file.jpg"
}
]
}
This approach is more secure than making the entire bucket public because it limits access to just the one file you specify. The bucket policy approach is also the recommended way rather than using ACLs, especially since many buckets now have ACLs disabled with the "Bucket owner enforced" setting.
Remember that any object made public will be accessible to anyone on the internet, so ensure the file doesn't contain sensitive information.
Sources
S3: is public access possible when Block all public access is on and object ownership is bucket owner enforced | AWS re:Post
Access control in Amazon S3 - Amazon Simple Storage Service
Module 5. Test your setup
Use Amazon S3 website hosting to host without a single web server - Hosting Static Websites on AWS
Relevant content
- asked 3 years ago
- asked 8 months ago
