Overview
Curated: · Written: · Reviewed:
Cloud IAM Policy Design
In one line
Design the smallest set of effective permissions a principal needs, then verify the outcome by evaluating the whole request. Reach for this whenever a role, service account or cross-account grant is created or reviewed.
Key definitions
- Implicit deny: if no applicable policy allows the action, the request fails.
- Explicit deny: wins over every allow in any applicable document, including SCPs and resource policies.
- Permissions boundary: a ceiling on identity-based grants. It grants nothing by itself.
- Session policy: caps one session at AssumeRole time. It intersects with the role's grants.
- Trust policy: says who may assume a role. It grants assumption only, never access inside the role.
- Confused deputy: a trusted service is steered into using its authority for another tenant. Controlled with
sts:ExternalIdand source conditions.
Formulas and complexity
For identity-based grants, the effective result is:
Resource-policy grants that name a principal directly are not limited by that principal's boundary, so treat that path as a separate escalation route.
Numbers to quote: DurationSeconds defaults to 3600 and is capped by the role's MaxSessionDuration, which can be set up to 43200. AWS managed policies are limited to 6,144 characters.
How it works
Every applicable document is collected and evaluated against the same request. An explicit deny ends evaluation. Otherwise the request needs an allow in an identity or resource policy, and that allow must also sit inside the SCP, boundary and session policy. Caps narrow a grant but never add one.
A resource path needs its own ARN form. s3:GetObject matches object ARNs such as arn:aws:s3:::bucket/2024/*. s3:ListBucket authorizes against the bucket ARN, so a listing grant on bucket/2024/* never matches. Scope it on arn:aws:s3:::bucket with an s3:prefix condition.
When to use and when not to
| Choice | Use when | Avoid when |
|---|---|---|
| Vendor job-function role | the role fits the job and the vendor maintains it | it over-grants and the blast radius is large |
| Reviewed custom role | the required permission set is stable | many near-duplicate variants accumulate unreviewed |
| Resource policy grant | one resource needs cross-account or service access | you must manage many principals on the resource |
| Session policy | one assumption needs narrower rights | you are using it to hide an over-broad role |
| Stored static key | a legacy system cannot federate | almost always; prefer temporary credentials |
Traps interviewers probe
- Reading one document. A boundary, a bucket policy or an SCP can decide the outcome. Fix: reconstruct the full request context and list each layer's effect.
- Assuming a boundary grants. An action missing from the identity policy stays denied even if the boundary allows it. Fix: the identity policy must allow, and the boundary must not block.
- Trusting the account root in a trust policy. Any principal in that account can then assume the role if its own policy allows. Fix: name the exact role ARN, and for vendors add
sts:ExternalId. Treat the external ID as a trust condition, not a secret. - Assuming absent tags behave one way. A
StringNotEqualsdeny matches when the key is missing. Fix: check each operator's behavior on absent keys and test it with a negative case. - Copying STS keys into code. The keys expire and the job fails mid-run. Fix: let the SDK's credential provider refresh the assumed-role session, and size
DurationSecondsandMaxSessionDurationto the run.
Interview tips
Open with the rule: the request is denied unless an allow applies and nothing denies it. Then name the layers you would check: SCP, boundary, identity policy, session policy, resource policy.
Expect these follow-ups:
- Why does an explicit deny beat an allow? Because evaluation stops at any applicable deny.
- How do you debug an AccessDenied? Read CloudTrail's
errorMessage, which names SCP denials. Runaws iam simulate-principal-policyfor identity, boundary and session layers. The simulator does not evaluate SCPs. - What does cross-account access need? Matching grants on both sides: a trust policy on the target role and an identity allow on the caller's side.
- Why does a listing fail while reads work?
ListBucketis scoped to the bucket ARN, not the object ARN.
30-second outline: state the goal (smallest effective permission set). Name the layers that cap and grant. Give one concrete grant with exact ARNs and the condition that binds it. Finish with the test: one expected allow and one expected denial, run against the simulator and CloudTrail.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.