Lesson 1 of 4 IAM Policies and Authorization

Tracing How AWS Evaluates Policy Types

This lesson explains exactly how AWS combines policy types to decide whether a request is allowed, which is central to the IAM domain, the most heavily weighted in the exam.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish policy types that grant permissions from those that only limit them.
  • Trace a request through the evaluation order.
  • Explain the permissions a cross-account request needs.
  • Describe policy elements and global condition keys.

Policy types

AWS evaluates several types of policy for every request, and the most important distinction is whether a type grants permissions or only limits them. Two types grant. Identity-based policies, managed or inline, are attached to users, groups and roles. Resource-based policies, such as S3 bucket policies, KMS key policies, SQS queue policies and role trust policies, are attached to resources and name the principals allowed.

Four types only limit, setting a maximum that grants cannot exceed. A permissions boundary limits one user or role. A service control policy (SCP) limits the principals in an organisation's accounts, and a resource control policy (RCP) limits the resources in them. A session policy limits a single assumed-role session. Access control lists (ACLs) are a legacy way of granting access on some resources, such as S3. An explicit deny in any policy always wins. The following table summarises the types.

TypeAttached toGrants or limits?
Identity-based (managed, inline)Users, groups, rolesGrants
Resource-based (incl. role trust policies)S3, KMS, SQS and other resourcesGrants
Permissions boundariesUsers, rolesLimits
Service control policies (SCPs)Organisation, OUs, accounts (principals)Limits
Resource control policies (RCPs)Organisation, OUs, accounts (resources)Limits
Session policiesA single assumed sessionLimits
ACLsSome resourcesGrants (legacy)
Sort into groups

Grants or limits?

Exam skills 4.2.3

Decide whether each policy type can grant permissions or only limits them.

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

Evaluation order

AWS evaluates every request against all applicable policies in a fixed order. The evaluation proceeds as follows.

  1. Implicit deny

    Every request starts as an implicit deny.

  2. Explicit deny

    Any explicit deny ends evaluation with a deny.

  3. SCPs and RCPs

    They must allow the action.

  4. Resource-based policies

    They may allow it.

  5. Boundaries and session policies

    Permissions boundaries and session policies must allow it.

  6. Identity-based policy

    It must allow the action.

Effective permissions are the intersection of limiting policies with granting ones. SCPs do not apply to the management account or service-linked roles.

The following diagram evaluates one cross-account s3:GetObject request through each policy layer.

One cross-account s3:GetObject evaluated through every layer. Explicit denies, SCPs, RCPs, the permissions boundary, the identity policy and the bucket policy all allow it, but the object is encrypted with a KMS key in the bucket account whose key policy does not allow kms:Decrypt, so the request fails with AccessDenied.
The scenario is illustrative.
Put in order

How AWS evaluates a request

Exam skills 4.2.3 · 4.2.4

Arrange the steps of IAM policy evaluation.

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

Cross-account requests

Both the caller's identity policy and the resource policy (or the target role's trust policy) must allow it. Within one account, a resource policy naming the principal is usually enough on its own.

True or false

Same account or cross-account?

Exam skills 4.2.1 · 4.2.3

Check how cross-account requests are authorised.

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

Policy elements and condition keys

IAM policies are composed of standard elements and can use condition keys to restrict access. The following list describes both.

  • Elements: Effect, Action/NotAction, Resource/NotResource, Principal (resource policies), Condition. NotAction in an Allow grants everything not listed.
  • Key global conditions: aws:PrincipalOrgID, aws:PrincipalArn, aws:SourceIp, aws:SourceVpc, aws:SourceVpce, aws:RequestedRegion, aws:MultiFactorAuthPresent, aws:SecureTransport, aws:PrincipalTag, aws:ResourceTag, aws:RequestTag, aws:CalledVia, aws:ViaAWSService.
Match the pairs

Global condition keys

Exam skills 4.2.3

Match each requirement with the global condition key that expresses it.

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

Evaluating one request through every layer

A developer's role in account 222222222222 calls s3:GetObject on a bucket in account 333333333333; the object is encrypted with a KMS key in the bucket account. Each layer must be checked in turn:

Layer                                   Must                         Result in this case
--------------------------------------  ---------------------------  -------------------------------------
Explicit denies anywhere                not match                    none
SCPs on the caller's account            allow s3:GetObject           FullAWSAccess -> allowed
RCPs on the bucket's account            allow                        org-only RCP; caller is in org -> allowed
Caller's permissions boundary           allow                        boundary allows s3:Get* -> allowed
Caller's identity policy                allow                        allows s3:GetObject on the bucket -> allowed
Bucket policy (cross-account)           allow the caller             allows role ARN -> allowed
KMS key policy (cross-account)          allow kms:Decrypt            MISSING -> request fails with AccessDenied

The request fails even though every S3-related policy allows it, because decrypting the object is a separate KMS call that the key policy does not permit, and the caller's IAM policy also needs kms:Decrypt on the key. Encryption is the most common hidden cause of cross-account S3 denials.

Check yourself

Can an SCP or a permissions boundary grant permissions?

Show answer

No. SCPs, RCPs, permissions boundaries and session policies only limit; they never grant.

Exam Tips

Remember for the exam

  • An explicit deny always wins.
  • For cross-account access, both the identity policy and the resource policy must allow the action.
  • SCPs, RCPs, permissions boundaries and session policies only limit; they never grant.
  • SCPs do not apply to the management account or to service-linked roles.
  • An allow with NotAction grants everything except the listed actions.