AWS Builder Center
The S3 “Access Denied” Trap

The S3 “Access Denied” Trap

The S3 “Access Denied” Trap

I made an S3 bucket, uploaded one file (my ISE 2102 mini project, a Word doc), copied the object URL, pasted it into my browser, and hit Enter.


Excuse me? My bucket. My file. My AWS account. Rude.
This is the exact moment a lot of people go hunting for the just make it public button. I almost did too. But the reason I got blocked is actually good news: S3 buckets are  private by default . Nobody gets in unless you let them in, and that includes the person who made the bucket.
Attempt 1: Make It Public (Please Don’t)
To open a bucket to the world, you attach a bucket policy like this:
json
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}]
The line to look at is "Principal": "*". That star means everybody. No login, no AWS account, nothing. If someone has the link, they can read your file.
I tried to save it anyway, and the console threw a big red banner at me.

That was Block Public Access doing its job. It’s switched on by default for new buckets, and it refuses any policy that makes things public. You’d have to go into the Permissions tab and turn it off yourself first.

Attempt 2: Presigned URLs
What I really wanted was simple: let one person open one file for a short time. A presigned URL does exactly that. It’s a normal link to your private file, with a signature and an expiry time built in.
I made one with a 60-second expiry and tested it:
I opened the link right away, and the file loaded fine.
I waited a minute and refreshed, and got AccessDenied with the message Request has expired.

The bucket stayed private the whole time. Only that one link worked, and only until the timer ran out. One warning, though: until it expires, anyone holding the link can open the file. So treat it like a temporary password, and don’t paste it in a big group chat.
What If I Need a Permanent Public Site?
That’s a different setup, and I haven’t built it yet. From what I’ve read, you keep the bucket private and put CloudFront in front of it, using Origin Access Control so only CloudFront can read from the bucket. That’s next week’s problem.
The Short Version
New buckets are private, and Block Public Access is on by default.
"Principal": "*" means the entire internet can read your files.
Need to share something for a bit? Use a presigned URL.
Need a real public site? Use CloudFront, with the bucket still locked.
Getting Access Denied? Don’t knock down the walls. Find the one permission you’re missing.
What Confused Me
Finding the presigned URL button. I spent way too long clicking around the Permissions tab, because that’s where all the security stuff lives. It’s not there. You open the file, then go to Object actions. The console also seems to move things around every other week, so good luck.
What’s the worst “just make it public” advice you’ve ever seen or been given? Stack Overflow, a group chat, a lecturer, anywhere. Reply and tell me. I’ll share the scariest ones next week.


Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article