AWS Builder Center

Securing my first S3 bucket: what I learned (and what confused me)

A cybersecurity student’s first hands-on AWS lab: locking down an S3 bucket with least-privilege IAM and CloudTrail logging, including the AccessDenied error that taught me the most.

Intro I’m a cybersecurity engineering student in Casablanca, Morocco. This month I did my first hands-on AWS lab to understand one of the most common cloud misconfigurations: publicly exposed S3 buckets. Here’s what I built, what went wrong, and what I’d do differently.
What I wanted to do Create a private S3 bucket, give access to only one IAM user, and log every access attempt.
Step 1: Create the bucket with Block Public Access enabled I created a bucket in [region] and kept “Block all public access” on. At first I thought this setting was enough by itself. It’s not: it only protects against public exposure, not against an over-permissive IAM policy.
Step 2: Create an IAM user with least privilege Instead of using  AdministratorAccess , I wrote a policy allowing only  s3:GetObject  and  s3:PutObject  on this one bucket. [Screenshot of the policy]
Step 3: Enable CloudTrail data events I enabled logging to see who accessed what. [Screenshot of a log entry]
What went wrong My first upload failed with  AccessDenied . The cause: [your real cause, e.g. I forgot the  /*  at the end of the resource ARN, so the policy applied to the bucket but not to the objects].
What I learned
  • Least privilege is simple in theory but needs precision in the ARNs.
  • Logging is what turns “I think it’s secure” into “I can prove it.”
  • [Your own takeaway]
What’s next I plan to try [AWS Config rules / GuardDuty / SCPs] and write a follow-up.
Question for the community: How do you test your IAM policies before deploying them?
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