Sub topic 15
How AWS evaluates a request: allow, deny, and implicit deny
This chapter assumes you can read IAM policy JSON, know the difference between identity-based and resource-based policies, and have seen a role trust policy. It covers how AWS combines those policies into one decision.
The three outcomes
Every request to AWS ends in one of three results:
- Explicit deny: a policy statement with
"Effect": "Deny"matches the request. The request is refused. - Allow: no explicit deny applies, and the applicable policies include a matching
Allow. - Implicit deny: nothing matches. All requests start denied (except those from the account root user), so no match means refusal.
The evaluation order
AWS gathers every policy that applies to the request and checks them in this order.
- Explicit deny. If any policy denies the action, evaluation stops. No
Allowanywhere can override it. - Guardrails. Service control policies (SCPs) and permissions boundaries do not grant access. They set a ceiling. If the request is outside that ceiling, it is implicitly denied.
- Allow. An identity-based policy or a resource-based policy must allow the action.
- Otherwise, the request is implicitly denied.
An explicit deny wins
Here is a policy that denies stopping instances unless MFA was used:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyStopWithoutMFA",
"Effect": "Deny",
"Action": "ec2:StopInstances",
"Resource": "*",
"Condition": {
"BoolIfExists": { "aws:MultiFactorAuthPresent": "false" }
}
}
]
}Suppose the user also has ec2:* in another policy. The Allow is real, but the Deny still wins whenever the condition matches.
BoolIfExists matters here. A plain Bool condition does not match when the key is missing from the request. That is the case for long-term access keys that did not sign in with MFA. BoolIfExists treats a missing key as a match, so those requests are denied too.
Same account and cross-account
Within one account, an identity-based policy or a resource-based policy can grant access on its own. If the resource policy names the specific user or role as principal, that is enough.
Across accounts, both sides must agree. The identity in the caller's account needs an allow, and the resource in the other account must also allow the caller. If either side is missing, the result is an implicit deny.
Worked example
A user has this identity-based policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
}
]
}| Request | Outcome | Reason |
|---|---|---|
| `s3:GetObject` on `amzn-s3-demo-bucket/a.txt` | Allowed | A matching `Allow` and no deny. |
| `s3:PutObject` on `amzn-s3-demo-bucket/a.txt` | Implicit deny | No statement mentions `PutObject`. |
| `s3:ListBucket` on `amzn-s3-demo-bucket` | Implicit deny | The resource ARN is the bucket, not `/*`. |
| `s3:GetObject`, with an SCP that excludes S3 | Implicit deny | The guardrail removes the permission. |
Exercise
A role has an identity-based policy allowing s3:* on all resources. A bucket policy explicitly denies s3:DeleteObject for that role. Can the role delete an object, and why?
Show answer
No. An explicit deny in any applicable policy overrides every allow, so the broad s3:* allow cannot restore s3:DeleteObject.