Overview
Curated: · Written: · Reviewed:
IAM & Security Fundamentals
In one line
Least privilege means each principal holds only the actions it needs on the resources it needs, granted through short-lived roles and scoped policies instead of long-lived keys. Reach for it whenever a human, workload or CI job needs cloud access, and whenever you are asked why a request was allowed or denied.
Key definitions
- Authentication: establishes who or what is calling. A failure here is a 401.
- Authorization: decides whether this principal may perform this action on this resource in this context. A failure here is a 403.
- Trust policy: says which principals may assume a role. Permissions policies say what the session may do.
- Permissions boundary: caps the maximum permissions one identity can receive. It grants nothing by itself.
- Session policy: narrows one assumed session further, passed at AssumeRole time.
- Confused deputy: a trusted service is tricked into acting for the wrong tenant. Fixed with an external ID (sts:ExternalId) or conditions on org ID or the OIDC sub claim.
Formulas and complexity
For a same-account request, the request is allowed only when no explicit deny applies and every applicable layer allows it:
STS credentials default to 1 hour and can run up to the role's MaxSessionDuration, which is 1 to 12 hours. Management events stay in CloudTrail event history for 90 days. Export the trail to S3 or CloudWatch Logs to keep them longer. Data events (S3 object-level, Lambda Invoke) are off by default and billed per event.
How it works
A request carries a principal, action, resource and context. AWS evaluates every applicable policy. An explicit deny ends the evaluation, and a missing allow fails the request by default.
When access fails, name the stage that stopped it before you edit any policy. Adding an allow to fix a denial at the SCP or boundary stage widens blast radius and usually outlives the incident.
When to use and when not to
| Choice | Use when | Avoid when |
|---|---|---|
| Temporary role session via federation | Humans, workloads, CI | Rarely avoid it for production access |
| Long-lived access key | Legacy system with no role support | Anything shared, embedded or unrotated |
| Identity policy grant | The principal's own workload needs the action | Cross-account (also needs resource or trust side) |
| Resource policy grant | Cross-account, or per-resource control | Same-account grants that a role already covers |
| Permissions boundary | Delegating role creation to teams | Expecting it to grant access |
| SCP | Org-wide ceilings such as region or service bans | Granting permissions; an SCP allow does not give access |
| ABAC with tags or attributes | Hundreds of teams and projects | Small, stable sets of fixed roles |
Traps interviewers probe
- Reading an SCP allow as access. An SCP allow only lifts the ceiling. Fix: confirm the identity policy grants the action. If an SCP allows dynamodb:* but the identity policy has no dynamodb:PutItem, the PutItem call is an implicit deny.
- Assuming the boundary and identity policy are unioned. The effective set is the intersection. Fix: an action must appear in both, so an identity allow outside the boundary still fails.
- Using the object ARN for list calls. ListObjectsV2 needs s3:ListBucket on the bucket ARN (arn:aws:s3:::bucket), with a prefix condition. Fix: grant on the bucket ARN and scope the prefix with a condition.
- Treating session expiry as containment. Deactivating an access key does not end sessions it already issued, and a second key created during the window keeps working. Fix: revoke the trust path, contain active sessions, and audit every key created during the window.
- Passing roles on
*. iam:PassRole on*lets a builder hand an admin execution role to a service it controls. Fix: scope the role ARN and add an iam:PassedToService condition.
Interview tips
Open by separating the three questions: authentication, authorization, accountability. Then name the mechanism you would use (federated role, scoped trust, explicit condition).
Expect these follow-ups:
- What fails if the bucket policy allows the role but the KMS key policy does not?
- Why does an external ID stop a confused deputy without authenticating anyone?
- Which claim stops a fork's pull request from assuming the deploy role? Pin aud and the sub claim to the exact repository and branch.
- Which CloudTrail fields show who assumed the role and what the session did? userIdentity, the session name or source identity, and the events that share that session.
30-second answer outline:
- Name the three questions and the 401 versus 403 distinction.
- Describe the mechanism: a federated identity assumes a short-lived role whose trust and permissions are both scoped.
- Name the evaluation stage that decides the case and the one control you would change.
- State the evidence: CloudTrail principal, session and outcome, and the date you reviewed it.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.