Lesson 1 of 30
Every AWS security incident that makes the news traces back to the same root cause: a permission that was broader than it needed to be. IAM is the system for making sure that never has to be true.
13 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
One IAM policy attached to a role grants `s3:*` on all buckets. A second policy attached to the same role explicitly denies `s3:DeleteObject`. Can that role delete an object?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
IAM (Identity and Access Management) answers one question for every single action taken in an AWS account: is this specific identity allowed to do this specific thing to this specific resource, right now? Three pieces make that decision:
s3:GetObject on arn:aws:s3:::my-bucket/* means "allowed to read objects from this one bucket," nothing more.Deny anywhere always wins over an Allow, no matter how many policies grant it elsewhere.{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::user-uploads/*"
}
]
}
A fresh role with zero policies attached — the default is deny. It can do nothing yet.
This policy, attached to a Lambda function's execution role, lets that function read objects from exactly one bucket — not write to it, not list other buckets, not touch anything else in the account. If that function's code has a bug or gets compromised, the blast radius is capped at "can read files from user-uploads," not "can do anything the AWS account can do." That capping is the entire point, and it's called the principle of least privilege: grant exactly what's needed to do the job, nothing kept "just in case."
s3:* and a different policy attached to the same identity denies s3:DeleteObject, the delete is still denied — there's no "most specific policy wins" resolution, deny is just absolute."Resource": "*") are a real, common security smell, not a convenience shortcut. A policy allowing s3:GetObject on * can read every object in every bucket the account owns — scoping resources to specific ARNs is what makes least privilege actually mean something instead of being a policy in name only."How would you make sure a Lambda function can only touch what it actually needs?" is a real, common question that tests whether a candidate reaches for least-privilege reasoning by default or grants broad permissions "to be safe" — which is precisely backwards, since broad permissions are what turn a small bug into a large incident.