Skip to content

Simple S3 Permissions Help

0

Simple S3 Permissions Help

What’s the easiest way to make just one file in my S3 bucket publicly viewable?

I’m still learning AWS and want to make just one image or file in my S3 bucket viewable by the public. I don’t want the whole bucket to be public — just that one file. What’s the best and safest way to do this?

Any help for a beginner is appreciated!

1 Answer
1
Accepted Answer

To make just one file in your S3 bucket publicly viewable, you'll need to follow these steps:

  1. 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
  1. 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

answered 8 months ago
AWS
EXPERT
reviewed 6 months ago
EXPERT
reviewed 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.