Sub topic 13
The full evaluation flow, step by step
This chapter assumes you know the earlier pieces: default deny, explicit deny, identity-based policies, resource-based policies, permission boundaries, session policies, and SCPs. Here they become one ordered procedure. You will use it to predict an outcome before you send a request, and to find the responsible policy after a request fails.
One decision, many policy layers
AWS makes one decision per request. The request carries a principal, an action, a resource, and context such as the source IP or whether TLS was used. AWS gathers every policy that applies to that request and evaluates all of them. The answer is Allow or Deny, and the default is Deny.
Policy types fall into two groups:
| Layer | Grants permissions? | Limits permissions? |
|---|---|---|
| Identity-based policy | Yes | No |
| Resource-based policy | Yes | No |
| Permission boundary | No | Yes, on an identity |
| Session policy | No | Yes, on one session |
| SCP | No | Yes, on accounts in an organization |
| RCP | No | Yes, on resources in an organization |
| VPC endpoint policy | No | Yes, on requests through that endpoint |
A grant must exist somewhere, and no limit may remove it. An explicit Deny in any policy of any type ends the evaluation.
The ordered checklist for a same-account request
Run these steps in order. The first step that decides the outcome wins.
- Explicit deny. If any applicable policy has a matching
Denystatement whose condition is met, the result is Deny. Nothing else is consulted. - Organization limits. If the account is in an organization, the SCPs must allow the action. Every level between the root and the account needs an allow. Resource control policies, where used, must also allow the action on the resource. A missing allow here is an implicit deny. The management account is not restricted by SCPs.
- Resource-based policy. Check the policy on the resource. In the same account, an allow that names the principal can be enough to grant access by itself. Whether the boundary and session policy still limit that grant depends on how the principal is named (see below).
- VPC endpoint policy. If the request goes through a VPC endpoint that has a policy, the policy must allow it.
- Identity-based policy. Look for an allow in the policies attached to the user or role, including those inherited through groups. If steps 3 and 5 both find no allow, the result is an implicit deny.
- Permission boundary. If the identity has a boundary, it must allow the action. The boundary only filters the identity policy's grant.
- Session policy. If the principal is a role session or federated user session created with a session policy, that policy must also allow the action.
- Result. If the request survived every step and some policy granted it, the result is Allow. Otherwise it is Deny.
The order is a mental model. AWS does not need to run the steps in this sequence, but the outcome is the same as if it did.
How resource policies interact with limits
A same-account resource policy can grant access without any identity policy allow. The subtle part is how much of the limiting machinery still applies to that grant.
- If the resource policy names the role by its role ARN, the role's boundary and any session policy still filter the request. Naming the role is not a bypass.
- If the resource policy names a user ARN, or the specific assumed-role session ARN, the grant is not limited by an implicit deny in a boundary or session policy.
- An explicit deny anywhere still wins. SCPs, RCPs, and VPC endpoint policies also still apply, because they sit outside the identity.
Check the exact principal format in the AWS documentation for your service before relying on this behavior in a design.
Cross-account requests
A cross-account request is evaluated in two accounts, and both must allow it.
- In the resource account, the resource-based policy must name the principal, either its account or the specific role or user. This is the trust side.
- In the principal's account, an identity-based policy must allow the action. That account's boundary, session policy, and SCPs apply to the principal.
- The resource account's SCPs and RCPs apply to the resource. The principal account's SCPs apply to the principal.
Missing either allow yields an implicit deny. The bucket policy from the earlier chapter shows this:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReportReaderRoleFromOtherAccount",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::222233334444:role/ReportReader" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}This policy is in account 111122223333. The ReportReader role in account 222233334444 also needs an identity policy that allows s3:GetObject on that bucket. If the role has a boundary, the boundary must allow it too.
A worked example
A role ReportWriter in account 111122223333 has this identity policy allowing s3:* and ec2:DescribeInstances. It also has this permission boundary:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BoundaryCeiling",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}The bucket also carries this statement:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::example-reports-bucket",
"arn:aws:s3:::example-reports-bucket/*"
],
"Condition": { "Bool": { "aws:SecureTransport": "false" } }
}
]
}Trace four requests from ReportWriter:
s3:PutObjectonexample-reports-bucket/2026/summary.csvover HTTPS. No deny matches. The identity policy allows it, and so does the boundary. Allow.- The same request over plain HTTP. The condition
aws:SecureTransportisfalse, so the explicit deny matches at step 1. Deny, whatever else allows it. s3:DeleteObjecton the same object over HTTPS. The identity policy allows it throughs3:*, but the boundary does not list it. Deny (implicit, at the boundary step).ec2:DescribeInstances. The identity policy allows it, but the boundary does not cover EC2. Deny (implicit).
The effective permissions are the overlap of the identity policy and the boundary, restricted by any explicit deny. Here that overlap is s3:GetObject and s3:PutObject on the bucket's objects, over TLS.
Predicting before you deploy
You can test a combination before it reaches production with the policy simulator:
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/ReportWriter \
--action-names s3:GetObject s3:PutObject s3:DeleteObject \
--resource-arns arn:aws:s3:::example-reports-bucket/2026/summary.csvFor each action the output shows EvalDecision, such as allowed, implicitDeny, or explicitDeny. Look at MatchedStatements to see which statement decided it. Treat the simulator as a close guide, not a perfect copy of a live request. It may not model the full request context, resource policies from other accounts, or every Organizations policy. You can pass context keys with --context-entries for condition testing.
Common mistakes
- Treating a boundary as a grant. A boundary alone allows nothing. With no identity policy allow, the role can do nothing.
- Adding an allow to fix an SCP deny. SCPs and RCPs are filters. An identity policy allow cannot override them. Change the organization policy or use a different account.
- Forgetting the second half of a cross-account grant. An allow on only one side leaves the request implicitly denied.
- Forgetting that explicit denies come from anywhere. A deny in an SCP, boundary, session policy, VPC endpoint policy, or resource policy beats every allow.
- Assuming a missing
Principalis an error. Identity policies have noPrincipal. The principal is whatever the policy is attached to.
Working order for a surprising AccessDenied
- Read the error text. Newer messages state the policy type that caused the deny, such as an identity-based policy, SCP, or resource-based policy.
- Look for explicit denies first, including conditions that may match unexpectedly (TLS, source IP, VPC, tags).
- Check the limits: SCPs, RCPs, VPC endpoint policy, boundary, session policy.
- Confirm that some policy grants the action. For cross-account requests, confirm that both sides grant it.
- Reproduce with the simulator, then confirm in CloudTrail, which records the failed call with its error code and request context.
Exercise
A role in account A has an identity policy that allows s3:GetObject on a bucket in account B. The bucket policy in account B has no statement mentioning the role or account A. The role has no boundary, and no SCP blocks the action. Is the request allowed? What change fixes it?
Show answer
It is denied. A cross-account request needs an allow on both sides, and the resource account has not granted anything to the role. Add a statement to the bucket policy in account B with the role (or account A) as Principal, allowing s3:GetObject on the bucket's objects. The identity policy in account A can stay as it is.
Exercise
A role has an identity policy allowing s3:* on all resources and a permission boundary allowing only s3:GetObject on arn:aws:s3:::example-reports-bucket/*. A bucket policy in the same account has an explicit Deny for s3:GetObject when aws:SecureTransport is false. List the outcome for a GetObject call over HTTPS and over HTTP, and for a PutObject call over HTTPS.
Show answer
GetObject over HTTPS is allowed, because the identity policy and boundary both allow it and no deny matches. GetObject over HTTP is denied by the explicit deny. PutObject over HTTPS is denied, because the boundary does not allow it (implicit deny).