Skip to content

How do I make a single file in my S3 bucket publicly accessible?

0

How do I make a single file in my S3 bucket publicly accessible?

I have a file in my S3 bucket that I want to share with others through a direct URL. I don’t want to make the whole bucket public, just this one file.

How can I do that in the AWS Console or using the right settings?

Beginner here, so simple instructions would be appreciated!

Tags to add:

Amazon S3

AWS Identity and Access Management (IAM)

S3 Bucket Policies

1 Answer
1
Accepted Answer

To make a single file in your S3 bucket publicly accessible, 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 by typing "confirm" when prompted and clicking "Confirm"
  1. Make the specific object (file) public:
  • Go to the "Objects" tab in your bucket
  • Select the file you want to make public
  • Click "Actions" and choose "Make public using ACL"
  • Confirm the action

Alternatively, if you prefer using bucket policies instead of ACLs (especially if you have "Bucket owner enforced" object ownership setting), you can:

  1. Go to the "Permissions" tab of your bucket
  2. Under "Bucket Policy", click "Edit"
  3. Add a policy that grants public read access to only your specific file:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForSingleObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/YOUR-FILE-NAME"
}
]
}

(Replace YOUR-BUCKET-NAME with your actual bucket name and YOUR-FILE-NAME with the path to your file) 4. Save the changes

After completing these steps, you should be able to access your file using its S3 object URL. Keep in mind that making objects public has security implications, so only do this for content that you intend to be publicly accessible.
Sources
How do I obtain a public access link for my S3 bucket resource? | AWS re:Post
Can't Open a Link to download a File | AWS re:Post
Module 5. Test your setup

answered 8 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.