Q&A-1Explain why an AWS request is denied despite an identity allow.
Answer
The short answer
An identity-based Allow is necessary but not sufficient. AWS allows a request only if every policy layer that applies to it allows and none of them denies. So the denial is coming from a different layer: most often a permissions boundary, a session policy, an SCP, or a cross-account resource policy that doesn't grant this principal.
How the layers combine
- Identity-based policy: grants, but is capped by the boundary and any session policy.
- Permissions boundary: intersects with the identity policy. It never grants; it only removes.
- Session policy (only when a role is assumed with one): another intersection.
- SCP (org): caps every principal in the account; never grants.
- RCP: caps resource-based permissions for resources in member accounts.
- Resource-based policy: cross-account, both the identity side and the resource side must allow. Same-account, a resource-policy allow is often sufficient on its own, except IAM role trust policies, where the trust policy and the identity policy must both allow
sts:AssumeRole. - Explicit deny: wins over every allow, anywhere.
Effective permission is roughly the intersection of identity policy, boundary, session policy and SCP, combined with the resource policy per the same/cross-account rule, minus any explicit deny.
Worked trace
Role arn:aws:iam::111122223333:role/AppRole, assumed as arn:aws:sts::111122223333:assumed-role/AppRole/session-1, calls s3:PutObject on arn:aws:s3:::reports-prod/2024/q4.csv in account 444455556666.
| Layer | Statement | Effect |
|---|---|---|
| Identity policy | Allow s3:PutObject on arn:aws:s3:::reports-prod/* | allow |
| Permissions boundary | Allow s3:GetObject, s3:ListBucket | PutObject not allowed |
| Bucket policy (444455556666) | Allow principal arn:aws:iam::111122223333:role/AppRole s3:PutObject | allow |
| SCP | FullAWSAccess | allow |
Result: AccessDenied. The boundary caps the identity policy, so the effective identity-side set has no s3:PutObject. Cross-account access needs the identity side to allow too, so the bucket-policy allow can't rescue it. The controlling layer is the boundary.
Debugging trade-offs
CloudTrail is ground truth: the AccessDenied event carries principal, action and resource, and for boundary or SCP denials the error text names the layer. It's after the fact and delivery lags by minutes. IAM Policy Simulator (aws iam simulate-principal-policy) lets you test a candidate fix before applying it, but it evaluates the policies you hand it against the context you supply: miss a condition key like aws:SourceIp or aws:PrincipalOrgID and it will tell you the call is allowed. IAM Access Analyzer finds external access and unused permissions, but won't explain one specific denial. Use CloudTrail to find the layer, the simulator to test the fix.
Failure modes to check
- Boundary strips the action (above). Detected by the boundary named in the error and by simulating with the boundary attached.
- SCP written with
NotAction: a deny-everything-except list that omits the action. The error names the SCP. - Cross-account bucket policy whose
Principalis the assumed-role session ARN instead of the role ARN. Session ARNs never match aPrincipal, so the grant silently doesn't apply. - Session policy on
AssumeRolethat omits the action: the intersection drops it. - Identity allow with a condition that fails (
aws:SourceVpce,aws:MultiFactorAuthAge) so the statement never matches the request.
Fix the one controlling layer, then re-run the call and a negative case (an action that should still be denied) to confirm you didn't widen access.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.