Policy Evaluation, Conditions and Resource Policies

Understand how AWS decides allow or deny across identity policies, resource policies, permission boundaries and SCPs, and write precise conditions.

Intermediate · about 6 hours · difficulty 3/5

Learn first: IAM Users, Groups, Roles and Policies

Debugging "Access Denied" is a core cloud engineer skill. To do it, you need to know how AWS combines every policy that applies to a request.

The evaluation logic

  1. By default everything is implicitly denied.
  2. An explicit Deny anywhere always wins.
  3. Otherwise, the request needs an Allow from an applicable policy, and must not be blocked by a limiting layer (SCP, permission boundary, session policy).

Policy types

  • Identity-based policies: attached to users, groups and roles.
  • Resource-based policies: attached to the resource itself (S3 bucket policies, SQS queue policies, KMS key policies, Lambda resource policies). They name a Principal and enable cross-account access.
  • Permission boundaries: a ceiling on what an identity's own policies can grant. Useful when you let developers create roles.
  • Service control policies (SCPs): a ceiling for whole accounts in AWS Organizations.
  • Session policies: further limit a single assumed-role session.

Conditions

Conditions make policies precise:

  • aws:SourceIp, aws:SourceVpce to restrict network origin.
  • aws:MultiFactorAuthPresent to require MFA.
  • aws:RequestedRegion to block regions you do not use.
  • aws:PrincipalTag and aws:ResourceTag for attribute-based access control (ABAC).

Pitfalls

  • Forgetting that S3 needs both bucket-level (arn:aws:s3:::bucket) and object-level (arn:aws:s3:::bucket/*) resources.
  • Debugging only the identity policy while a bucket policy or SCP denies the call.

You are ready to move on when you can take an "Access Denied" error, use the IAM policy simulator and CloudTrail to find the denying policy, and fix it with the narrowest change.

Key concepts

  • Implicit deny, explicit deny, allow
  • Resource-based policies
  • Permission boundaries
  • Session policies
  • Condition keys
  • ABAC with tags
  • IAM policy simulator

Mini project

Write a bucket policy that allows reads only from your home IP and only over HTTPS, plus an identity policy that denies all actions outside ap-south-1. Test both with the policy simulator and the CLI. Use an empty or tiny bucket within free tier and delete it when done.

Check yourself

A role's identity policy allows s3:GetObject on a bucket, but the request is denied. Name three other places the deny could come from.

Free resources