AWS IAM Policy Evaluation Explained
AWS IAM authorization is the process of deciding whether an authenticated principal may perform one particular action on one particular AWS resource. IAM evaluates identity-based policies, resource-based policies, permissions boundaries, and explicit denies to make that decision.
This is the mechanism behind familiar errors such as AccessDenied, not authorized to perform, and because no identity-based policy allows the action. Understanding the evaluation model turns those messages from guesswork into a structured debugging problem.
The problem IAM solves
An AWS API request needs more than a valid access key or an authenticated role. Authentication answers who is calling. Authorization answers what that caller may do.
Without a policy system, each AWS service would need a separate, inconsistent access-control configuration. IAM provides a common language for expressing permissions and a common decision process. A policy can say, for example, that a deployment role may read objects from one S3 bucket but may not delete them.
The result is not a single permission attached to a user. It is the outcome of evaluating several possible sources of permission and restriction against the request.
Start with the request
For an API request, IAM considers a request context that includes:
- The principal, meaning the authenticated identity making the call: an IAM user, role session, or another AWS identity.
- The action, such as
s3:GetObjectorec2:DescribeInstances. - The resource, identified by an ARN (Amazon Resource Name).
- The request details, such as the source IP, region, tags, or whether a secure transport connection was used.
A policy statement matches only if its Action, Resource, Principal where applicable, and Condition requirements match that context. A matching statement can allow the request or deny it.
IAM begins with an implicit deny: a request is not allowed unless an applicable policy produces an allow. An implicit deny is simply the absence of permission; it is different from an explicit Deny statement.
Identity-based policies
An identity-based policy is attached to an IAM user, group, or role. It describes what that identity may do, usually by naming actions and resources.
For example, a role policy might contain a statement equivalent to:
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::reports-prod/*"
}
This allows the role to read objects under that bucket path, assuming no other applicable control blocks the request. A group policy can give its member users permissions, and a role policy gives permissions to sessions created from that role.
Identity policies are generally the first place to look when an error says no identity-based policy allows an action. But they are not the only source of permission.
Resource-based policies
A resource-based policy is attached to the resource rather than to the caller. S3 bucket policies, SQS queue policies, SNS topic policies, and KMS key policies are common examples. Such a policy can grant access to a specified principal, including an AWS account, role, or user.
This is useful when the resource owner needs to control access directly, especially for cross-account access. For example, an S3 bucket policy in account B can name a role from account A and allow that role to read objects.
In the same account, an allow from an applicable identity-based policy or resource-based policy can be sufficient. In a cross-account case, authorization normally requires an allow on both sides: the caller's account must delegate the permission through an identity policy, and the resource-owning account must grant it through the resource policy. A resource policy cannot make an unauthenticated caller valid, and it cannot override an explicit deny.
The policy attached to an IAM role that controls who may assume it is also a resource-based policy. That trust policy governs the sts:AssumeRole request; it does not automatically grant permissions to the role after assumption. The role's identity policies govern those later API calls.
Permissions boundaries
A permissions boundary is a policy attached to an IAM user or role that sets the maximum permissions identity-based policies can grant to that identity. It is useful for delegation: a team can create or modify roles while an administrator guarantees that those roles cannot exceed a predefined ceiling.
An identity-based allow and a boundary must both permit the action. Conceptually:
Effective identity permission = identity-policy allows intersected with boundary allows.
If the role policy allows s3:DeleteObject but the boundary allows only s3:GetObject, the delete is not authorized. The boundary does not grant permissions by itself; it only limits permissions that other identity policies attempt to grant.
There is an important resource-policy detail. A direct grant in a resource policy can behave differently from an identity-policy grant. In particular, a grant naming an IAM user ARN is not limited by that user's permissions boundary. Grants to role sessions can likewise bypass implicit restrictions from the role's identity policy, boundary, or session policy. This is why resource policies should name the intended principal carefully and why a boundary is not a universal deny mechanism.
Explicit denies always win
An explicit deny is a policy statement with "Effect": "Deny". If any applicable policy explicitly denies the request, the final answer is deny, even when another policy allows it.
This rule lets administrators create guardrails. A policy might allow a deployment role to use many S3 actions while explicitly denying access to objects tagged as confidential, or deny actions outside approved regions. The deny wins over an allow from an identity policy, a resource policy, or both.
The practical evaluation model
A useful mental model is:
- Authenticate the request and identify its principal.
- Build the request context: action, resource, and conditions.
- Find matching statements in identity-based and resource-based policies.
- If no applicable allow exists, deny because of the implicit deny.
- Apply limits such as a permissions boundary where they govern the type of grant.
- If any applicable statement is an explicit deny, deny regardless of the allows.
- Otherwise, allow the request.
AWS also has higher-level controls such as organization service control policies and role-session policies, which can impose additional limits. They do not change the central rule: an allow must apply, and an explicit deny overrides it.
When debugging an AccessDenied error, compare the exact principal, action, resource ARN, and condition values with every relevant policy. Then ask two separate questions: where is the required allow? and is there an explicit deny or maximum-permission control blocking it?