Skip to content
Aesthetic Infra

    AWS IAM policies: follow the request, find the Deny

    Hieu Vu

    16 min read
    On this page

    An Allow answers who may do something. A permissions ceiling answers how far that permission can go. A matching explicit Deny overrides both. Follow one request through each layer to see which policy actually decides.

    Situation and definition

    ShopViet has application account A 111122223333 and data account B 444455556666. User ops-binh needs to read and delete objects in bucket reports. The question is not whether one policy says Allow: it is whether the complete request context has a valid grant and passes every applicable restriction.

    A policy usually expresses Effect, Action, Resource and optional Condition. Resource-based policies also identify a Principal. IAM users and roles start with implicit deny; account root has different default permissions and remains subject to applicable Organizations restrictions. Prerequisites: AWS accounts, S3 object ARNs and the difference between an IAM user and a role.

    Source: IAM policies and permissions.

    Picture it as

    Real lifeAWS meaning
    Employee badge: what its holder may doIdentity-based policy
    Guest list at a room: who may enterResource-based policy
    Building rules: limits, not an entry ticketBoundary, SCP, RCP and session policy

    Source: AWS evaluation logic.

    Mechanism: follow one request

    The sequence below summarizes the documented decision logic; it does not describe separate network hops or AWS internal execution timing. A Deny must match the action, resource, principal context and conditions to matter.

    From request to decision
    1. Explicit Deny?

      A matching Deny in any applicable policy ends evaluation with explicit deny.

    2. Organizations

      Check resource-side RCPs and caller-side SCPs where applicable. They restrict grants; they do not create grants.

    3. Resource grant

      In the same account, a direct user or session grant may be sufficient. Role ARN grants still have boundary/session limits.

    4. Identity and ceilings

      For the identity-based path, find an Allow and check the attached boundary and any session policy.

    5. Decision

      A valid grant surviving the applicable restrictions produces Allow. Otherwise the result is implicit deny.

    5 / 5 · A valid grant surviving the applicable restrictions produces Allow. Otherwise the result is implicit deny. Sequence complete.

    RCPs and SCPs are shown in one Organizations step for readability. Their scope differs: resources versus principals. When RCPs are enabled, the automatically attached RCPFullAWSAccess supplies an Allow baseline; do not model an unattached RCP as a missing grant.

    Source: AWS evaluation logic.

    Predict before playback

    SCP Allow *, boundary Allow s3:*, but no identity Allow and no resource grant: can ops-binh read an object? No. Both policies are ceilings. Neither grants the request. Compare A and B below before replaying them.

    Source: Policy types.

    Six cases: change one thing

    All six cases call s3:DeleteObject. Unless a case says otherwise, there is no matching explicit Deny, applicable Organizations policies allow the action, and no session policy is passed. The case summaries remain visible during playback.

    CaseChange from baseline BDecision
    ARemove the identity AllowImplicit deny
    BIdentity and boundary Allow s3:*Allow
    CBoundary only allows s3:Get*Implicit deny
    DAdd SCP Deny s3:Delete*Explicit deny
    ENo identity grant; same-account bucket names the user ARNAllow
    FSame as E, but move bucket to BImplicit deny
    A · Ceilings without a grant
    1. Deny and Organizations

      No matching Deny; the Organizations ceiling permits this action.

    2. Resource policy

      No bucket policy grants the request.

    3. Identity policy

      There is no Allow. The boundary cannot fill the gap.

    4. Implicit deny

      Add a suitable grant; broadening a ceiling does not grant access.

    4 / 4 · Add a suitable grant; broadening a ceiling does not grant access. Sequence complete.

    B · Add an actual Allow
    1. Deny and Organizations

      No matching Deny; applicable Organizations restrictions permit the request.

    2. Identity policy

      Allow s3:* covers s3:DeleteObject on the example resource.

    3. Boundary

      Allow s3:* also contains the requested action.

    4. Allow

      The identity grant survives the applicable ceilings.

    4 / 4 · The identity grant survives the applicable ceilings. Sequence complete.

    C · Outside the boundary
    1. Identity policy

      The same Allow s3:* grant is present.

    2. Boundary

      Only s3:Get* is allowed. s3:DeleteObject is outside that set.

    3. Implicit deny

      No Deny statement is needed. The requested action is outside the identity-based permissions ceiling.

    3 / 3 · No Deny statement is needed. The requested action is outside the identity-based permissions ceiling. Sequence complete.

    D · One matching Deny
    1. Request

      ops-binh requests s3:DeleteObject.

    2. SCP Deny

      Deny s3:Delete* matches the action and example resource.

    3. Explicit deny

      Stop. Neither AdministratorAccess nor a bucket Allow can override this Deny.

    3 / 3 · Stop. Neither AdministratorAccess nor a bucket Allow can override this Deny. Sequence complete.

    E · A direct user grant in the same account
    1. Scope

      User ops-binh and reports are both in A. No applicable explicit Deny or Organizations restriction blocks the action.

    2. Bucket policy

      Principal is arn:aws:iam::111122223333:user/ops-binh, with Allow s3:DeleteObject.

    3. Allow

      For this direct IAM-user grant, an implicit deny in the identity policy or boundary does not remove the resource grant.

    3 / 3 · For this direct IAM-user grant, an implicit deny in the identity policy or boundary does not remove the resource grant. Sequence complete.

    F · Move only the bucket to another account
    1. Scope

      ops-binh stays in A; reports is now in B.

    2. Resource side

      The bucket in B still grants the user access.

    3. Caller side

      The user in A still has no identity Allow for this request.

    4. Implicit deny

      Cross-account access needs authorization on both sides. The bucket grant alone is insufficient.

    4 / 4 · Cross-account access needs authorization on both sides. The bucket grant alone is insufficient. Sequence complete.

    Principal precision matters: E names an IAM user ARN, not an account principal or a role ARN. A grant to a role ARN remains limited by implicit denies in its boundary and session policy. Direct grants to a role session follow different rules. Explicit Deny remains decisive for all these paths.

    Source: Principal-specific evaluation.

    Source: Cross-account evaluation.

    Effective permissions: the intersection

    For the identity-based path without a separate resource grant, keep only permissions inside every applicable ceiling, then remove every matching explicit Deny. This intersection is a reasoning tool for this path, not a universal formula for every resource-policy principal.

    DataEng · Four actions become one (illustrative)
    1. Identity

      Allow s3:*, ec2:* and iam:* initially covers GetObject, DeleteObject, RunInstances and CreateUser.

    2. Boundary

      Allow only s3:* and ec2:*. iam:CreateUser falls outside the boundary.

    3. SCP

      Deny ec2:* removes ec2:RunInstances. Its final classification is explicit deny, regardless of where it is drawn.

    4. Session

      A session policy allows only s3:Get*. s3:DeleteObject is outside this session.

    5. Remaining action

      s3:GetObject survives. The column order explains set narrowing, not the order in which AWS searches for Deny.

    5 / 5 · s3:GetObject survives. The column order explains set narrowing, not the order in which AWS searches for Deny. Sequence complete.

    Source: Evaluation logic.

    Compare the policy groups

    The source lesson groups the following into six teaching categories. AWS currently documents nine policy types, separating SCP from RCP and also listing VPC endpoint policies and RAM resource shares.

    GroupAttached toGrants permissions?
    Identity-basedUser, group or roleYes; no Principal element
    Resource-basedBucket, key, queue, role and supported resourcesYes; names a Principal
    Permissions boundaryUser or roleNo; limits identity grants
    SCP / RCPOrganizations root, OU or accountNo; principal-side / resource-side guardrails
    Session policySTS sessionNo; narrows identity-based session permissions
    ACLS3 bucket or objectCoarse legacy grants; not JSON policy syntax

    Source: AWS policy types.

    Source: SCP scope.

    Source: RCP scope.

    Grant permissions or set a ceiling

    Identity and resource policies are the main grant mechanisms in these examples. Boundaries, session policies and Organizations guardrails constrain grants. An Allow in a ceiling means that layer permits the action; it does not make the action usable on its own. New S3 buckets default to Bucket owner enforced Object Ownership with ACLs disabled; prefer policy-based access control.

    Source: S3 Object Ownership.

    Identity policies: managed or inline

    TypeOwnershipReuse and lifecycle
    AWS managedAWSReusable; AWS can update it
    Customer managedYour accountReusable; you manage changes
    InlineOne identityOne-to-one; removed with its identity
    Delete Analyst: what survives?
    1. Before deletion

      Analyst and Etl share managed policy ReportsRead. Analyst alone has inline policy AnalystTemp.

    2. Remove attachments

      Before API deletion, remove the inline policy and detach managed policies; satisfy any other DeleteRole requirements.

    3. After deletion

      AnalystTemp has no independent lifecycle. ReportsRead survives and remains attached to Etl.

    3 / 3 · AnalystTemp has no independent lifecycle. ReportsRead survives and remains attached to Etl. Sequence complete.

    Source: Managed and inline policies.

    Source: DeleteRole requirements.

    Resource policies and service-specific rules

    PolicyResourceQuestion it answers
    Bucket policyS3 bucketWho may access these objects?
    Key policyKMS keyWho may use or administer this key, directly or through IAM delegation?
    Trust policyIAM roleWho may assume this role?
    Queue / topic / function policySQS / SNS / LambdaWhich principal or service may call this resource?
    Endpoint policyVPC endpointWhich otherwise-authorized requests may traverse this endpoint?

    An endpoint policy is an additional boundary for requests using the endpoint, not a replacement for IAM or resource policies. KMS key policies have their own authorization requirements; grants are another KMS mechanism.

    Source: Endpoint policies.

    KMS · IAM delegation enabled
    1. Key policy

      An applicable key-policy statement grants the account principal permission to delegate the requested operation through IAM.

    2. IAM policy

      Dev has Allow kms:Decrypt on this key. Delegation makes this IAM grant usable.

    3. Allow

      Assuming all conditions and other restrictions pass, Dev can decrypt.

    3 / 3 · Assuming all conditions and other restrictions pass, Dev can decrypt. Sequence complete.

    KMS · IAM Allow alone is insufficient
    1. Key policy

      Only KeyAdmin is authorized. There is no applicable IAM delegation, direct Dev grant or KMS grant.

    2. IAM policy

      Dev has kms:* but that alone cannot authorize this key operation.

    3. Implicit deny

      Authorize the intended operation through an appropriate key policy or grant; do not merely widen IAM.

    3 / 3 · Authorize the intended operation through an appropriate key policy or grant; do not merely widen IAM. Sequence complete.

    Source: KMS key policies.

    Two ways across accounts

    Direct access: keep the original identity
    1. Account A

      The caller identity policy allows s3:GetObject on the object ARN in B.

    2. Account B

      The bucket policy grants the caller access. Both sides pass applicable restrictions.

    3. Request

      The caller still uses its original identity. It can use other A permissions that remain authorized.

    3 / 3 · The caller still uses its original identity. It can use other A permissions that remain authorized. Sequence complete.

    AssumeRole: use a new session identity
    1. Caller permission

      A allows sts:AssumeRole on Role B.

    2. Trust

      Role B trusts the caller, and all trust conditions and applicable restrictions are satisfied.

    3. STS credentials

      The caller obtains temporary credentials for a Role B session.

    4. Role permissions

      Object access is evaluated for Role B. The original user permissions are not added to the session.

    4 / 4 · Object access is evaluated for Role B. The original user permissions are not added to the session. Sequence complete.

    Assuming B does not inherently prevent access back to A: B can be granted cross-account access to A separately. What changes is which identity must be authorized. A role trust policy controls assumption; it does not itself grant S3 permissions.

    Source: Cross-account evaluation.

    Three questions to choose a policy

    1. Grant or restrict? A new permission needs a grant. A limit needs a ceiling or an applicable Deny.
    2. Caller or resource? Identity policies belong to the caller; resource policies belong to the target.
    3. What scope? Boundary for a user/role, session policy for temporary narrowing, SCP for principals in member accounts, RCP for supported resources in member accounts.
    DataReader in B needs reports in A
    1. Intent

      This is a new grant, not a new ceiling.

    2. Resource owner

      A owns the bucket, so A can grant DataReader access with its bucket policy.

    3. Caller owner

      B must also grant DataReader the requested object action. A cannot attach identity policies to a role in B.

    3 / 3 · B must also grant DataReader the requested object action. A cannot attach identity policies to a role in B. Sequence complete.

    Limit a Sandbox OU to a region
    1. Intent

      Restrict member-account principals, including root, rather than grant permissions.

    2. Scope

      Choose an SCP for the OU. It does not constrain the Organizations management account or service-linked roles.

    3. Conditions

      Use aws:RequestedRegion with reviewed global-service exceptions. Region restrictions need service-specific review.

    3 / 3 · Use aws:RequestedRegion with reviewed global-service exceptions. Region restrictions need service-specific review. Sequence complete.

    Source: SCP scope and exceptions.

    When policies work together

    NeedCombination
    Direct cross-account S3Caller identity + bucket policy
    Assume a role in another accountCaller identity + target trust + target role permissions
    Use a KMS key through IAMKey-policy delegation + IAM grant
    Delegate role creation safelyConditional CreateRole grant + mandatory boundary + protection against removing it
    Access through a VPC endpointIAM / resource authorization + endpoint restriction
    CreateRole · Boundary omitted
    1. Request

      Dev calls iam:CreateRole without PermissionsBoundary.

    2. Condition

      The only Allow requires iam:PermissionsBoundary to equal DevBoundary. The condition does not match.

    3. Implicit deny

      The role is not created. This is absence of a matching Allow, not an explicit Deny.

    3 / 3 · The role is not created. This is absence of a matching Allow, not an explicit Deny. Sequence complete.

    CreateRole · Boundary supplied
    1. Request

      Dev supplies the required DevBoundary ARN.

    2. Condition

      The conditional Allow matches, assuming every other requirement passes.

    3. Created role

      The role starts with its boundary. Identity policies attached later cannot exceed that boundary.

    4. Protect the ceiling

      Also restrict deleting/changing the boundary and editing its managed policy. Creation alone is not a complete delegation design.

    4 / 4 · Also restrict deleting/changing the boundary and editing its managed policy. Creation alone is not a complete delegation design. Sequence complete.

    Source: Permissions boundaries.

    Common traps

    ClaimCorrection
    SCP Allow grants S3It only permits the grant to survive that ceiling.
    Any same-account resource Allow skips every ceilingThe exact user, role or session principal matters.
    A more specific Allow defeats DenyA matching explicit Deny wins.
    An IAM group can be a bucket PrincipalA group is not a request principal.
    External ID is a secret passwordIt is a third-party confused-deputy safeguard, not a secret.

    Source: Third-party access and External ID.

    Source: Principal element.

    Question wording to policy choice

    RequirementStarting point
    Restrict a member account or OU, including rootSCP
    Let Dev create roles under a ceilingBoundary + conditions and anti-removal controls
    A third-party provider assumes a roleTrust policy + External ID condition
    Limit access to organization membersReview aws:PrincipalOrgID in the resource policy
    Permit only a VPC endpoint pathReview aws:SourceVpce and service-principal exceptions
    Restrict requested regionsSCP with aws:RequestedRegion and reviewed exceptions

    Source: Global condition keys.

    Read the JSON, then replay the decision

    These fragments illustrate policy structure. Replace names and ARNs, validate the full policy and test in a non-production account before use. They do not form a complete deployment configuration.

    Identity-based: attach to Analyst in A; the identity is implicit, so there is no Principal.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::reports/*"
        }
      ]
    }

    Resource-based: attach to reports in B. This is the resource half of cross-account authorization; the preceding identity policy supplies the caller half.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "AWS": "arn:aws:iam::111122223333:role/Analyst"
          },
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::reports/*"
        }
      ]
    }

    SCP: this deliberately shortened region-deny example is for reading NotAction, not a production-ready region guardrail. Review the global-service list and regional STS behavior for your environment.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Deny",
          "NotAction": [
            "iam:*",
            "organizations:*",
            "sts:*",
            "cloudfront:*",
            "route53:*",
            "support:*"
          ],
          "Resource": "*",
          "Condition": {
            "StringNotEquals": {
              "aws:RequestedRegion": "ap-southeast-1"
            }
          }
        }
      ]
    }
    SCP · EC2 in us-east-1
    1. Action

      ec2:RunInstances is not excluded by NotAction, so this statement covers it.

    2. Resource

      Resource * covers the example request.

    3. Condition

      us-east-1 differs from ap-southeast-1, so StringNotEquals is true.

    4. Explicit deny

      The Deny statement matches, including for root of an affected member account.

    4 / 4 · The Deny statement matches, including for root of an affected member account. Sequence complete.

    SCP · IAM with the same region context
    1. Action

      iam:CreateRole matches the iam:* exception inside NotAction.

    2. Not applicable

      This Deny statement does not apply. It does not grant the action.

    3. Continue evaluation

      The Organizations Allow baseline and a valid grant are still needed, along with every applicable restriction.

    3 / 3 · The Organizations Allow baseline and a valid grant are still needed, along with every applicable restriction. Sequence complete.

    Source: SCP region restriction examples.

    Self-check: predict, then explain

    1. dev-app has AdministratorAccess, but its boundary only allows s3:* and cloudwatch:*. There is no separate resource grant. It calls ec2:RunInstances. Answer: implicit deny, because the action is outside the boundary. No Deny statement was specified.

    2. Bucket B allows role Analyst from A, but Analyst has no S3 identity Allow. Answer: implicit deny. Direct cross-account access requires authorization on both sides.

    3. Root in a member account calls EC2 in us-east-1 and an applicable SCP explicitly denies that request. Answer: explicit deny. Root does not override an applicable SCP.

    Transfer: a broker assumes a shared role with identity permission s3:GetObject on customers/*, passing a session policy limited to customers/42/*. With no separate resource grant, can that session read customers/7/invoice.pdf? Answer: implicit deny: the object is outside the session policy. Per-session narrowing avoids creating one role per customer, but tenant isolation also requires protecting the broker and checking all other grant paths.

    Source: Session policies.

    Core terms and a debugging checklist

    TermMeaning
    PrincipalThe caller identity, account, session or AWS service; not an IAM group.
    Implicit denyNo valid grant survives the applicable restrictions.
    Explicit denyAn applicable Effect: Deny statement matches the request.
    ConditionContext test such as source endpoint, organization, transport, tags or region.
    ABACAttribute-based access control, often comparing principal and resource tags.
    Role ARN / session ARNDifferent principal forms with different resource-grant evaluation rules.

    When debugging, capture the actual caller ARN, action, resource and conditions first. Find applicable explicit Denies, then Organizations restrictions, then the grant path and its ceilings. For KMS or role assumption, inspect the key or trust policy as well. The animations explain why a request can fail; the AWS documentation and the real request context decide which rules apply.

    Source: Evaluation reference.

    Source: ABAC.

    Written by

    Hieu Vu

    Software engineer writing about cloud infrastructure, DevOps and reliable systems.