Lesson 3 of 6 AWS IAM

Tracing How AWS Evaluates Policies

This lesson explains the fixed logic AWS uses to combine the policies that apply to a request, since exam questions often turn on why a request was allowed or denied.

Learning outcomes

After completing this lesson, you will be able to:

  • Trace a request through implicit denies, explicit denies and allows.
  • Explain how SCPs, permissions boundaries and session policies limit permissions.
  • Explain how permissions boundaries make delegated role creation safe.
  • Troubleshoot an unexpected denial systematically.

How a request is evaluated

IAM evaluates every request against all the policies that apply to it, following a fixed logic. Every request starts implicitly denied: if nothing allows it, it fails. If any applicable policy contains an explicit deny for the action, evaluation ends immediately with a deny, whatever any other policy allows.

Otherwise, the request needs an explicit allow in an identity-based or resource-based policy. In addition, every limiting policy in play must also allow the action: service control policies and resource control policies from AWS Organizations, permissions boundaries and session policies. These limiting policies never grant access themselves; they only set the maximum that other policies can grant.

The following diagram shows the evaluation as a sequence of checks.

How IAM evaluates a request. An explicit deny in any applicable policy ends evaluation with a deny. Otherwise the request needs an explicit allow in an identity-based or resource-based policy, and every limiting policy in play, such as service control policies, resource control policies, permissions boundaries and session policies, must also allow it. If any check fails, the request is denied.
Limiting policies never grant access themselves; they can only stop an allow from taking effect.
Put in order

Evaluating a request

Exam skills 1.1.2 · 1.1.4

Put the stages of IAM policy evaluation in order.

Log in to try this activity Interactive activities are free with an account.

Limiting policy types

Some policy types grant no permissions at all. They set the maximum permissions available, and a request succeeds only if it is also allowed by an identity or resource policy. Service control policies (SCPs) cap what users and roles in an organisation's member accounts can do. Resource control policies (RCPs) cap what can be done to resources in those accounts, whoever the caller is, for example preventing access from outside the organisation.

A permissions boundary caps a single user or role. It lets administrators delegate role creation to developers safely, because any role they create can never exceed the boundary. A session policy, passed when a role is assumed, caps that one session, for example to give a script less than the role's full permissions. The following table summarises what each type limits.

PolicyCaps
Service control policies (SCPs)Principals in accounts of an organisation
Resource control policies (RCPs)Resources in accounts of an organisation
Permissions boundariesA single user or role
Session policiesA single assumed-role session

They never grant, only cap. Example: a role allows s3:*, its boundary allows only s3:GetObject, and an SCP denies S3 outside eu-west-1. The developer can only read objects, only in eu-west-1: the effective permission is the intersection.

Match the pairs

Limiting policies

Exam skills 1.1.2 · 1.1.4

Match each limiting policy type with what it caps.

Log in to try this activity Interactive activities are free with an account.

Permissions boundaries for delegation

A permissions boundary lets administrators delegate role creation safely. Developers may create roles only if they attach a given boundary, so no role they create can exceed it, even if they attach AdministratorAccess.

The following diagram shows how a boundary caps a role that a developer creates.

A permissions boundary as an intersection. A developer creates a role and attaches AdministratorAccess, but the role was created with the required boundary, which allows only Amazon S3 and DynamoDB. The role's effective permissions are only what both the identity policy and the boundary allow.
The boundary does not grant S3 or DynamoDB access by itself; the identity policy must still allow it.

Resource-based policies

A resource-based policy is attached to a resource, such as an S3 bucket, an SQS queue or a KMS key, and names the principals allowed to use it. Whether it is enough on its own depends on whether the request crosses an account boundary.

Within the same account, either policy is sufficient: if the bucket policy allows a role to read, the role needs no identity policy for it, and the reverse is also true. For a cross-account request, both accounts must agree. The resource policy in the owning account must allow the caller's account or role, and the caller's identity policy in its own account must allow the action on that resource. This protects each account: neither can grant access to the other's resources, or for the other's principals, alone. The following table summarises the rule.

ScenarioWhat must allow
Same accountEither the identity policy or the resource policy
Cross-accountBoth the resource policy and the caller's identity policy

KMS keys are an exception: the key policy must allow access, even in the same account, before IAM policies take effect.

Scenario questions

Same account or cross-account?

Exam skills 1.1.5

Work out which policies must allow each request.

Log in to try this activity Interactive activities are free with an account.

Troubleshooting a denial

When a request is unexpectedly denied, a systematic review usually finds the cause. The first step is to look for an explicit deny, in a service control policy, resource control policy, resource policy, permissions boundary or session policy, because a deny anywhere overrides every allow. If there is none, the cause is a missing allow. Access denied error messages often name the type of policy responsible, which narrows the search.

Encrypted resources add another layer: reading an object encrypted with an AWS KMS key also requires permission to use the key, so a request can be denied even when the S3 permissions are correct. The IAM policy simulator tests how an identity's policies evaluate a given action and resource, without making the request.

Worked example

An allow that still does not work

A developer's role has AdministratorAccess, yet cannot launch instances in ap-southeast-2. The account is in an organisation, so the architect checks every layer of policy:

LayerResult
Identity policyAllows everything
Permissions boundaryNone
SCP on the OUDenies all actions outside eu-west-1 and eu-central-1
OutcomeExplicit deny from the SCP wins

The SCP is working as intended: the company operates only in two EU Regions for data residency. No change to the developer's IAM policy could override it. This is the core rule of evaluation: an explicit deny in any applicable policy ends the decision.

Check yourself

What does a permissions boundary do?

Show answer

It sets the maximum permissions that identity-based policies can grant to a user or role. It grants nothing by itself.

Exam Tips

Remember for the exam

  • An explicit deny always wins over any allow.
  • Effective permissions are the intersection of the identity policy and every limiting policy.
  • Permissions boundaries let you delegate the creation of roles without privilege escalation.
  • Cross-account access needs both the resource policy and the caller's identity policy to allow it.
  • If access to an encrypted object is denied despite S3 permissions, KMS key permissions are missing.