AWS IAM policies: follow the request, find the Deny
On this page
- Situation and definition
- Picture it as
- Mechanism: follow one request
- Predict before playback
- Six cases: change one thing
- Effective permissions: the intersection
- Compare the policy groups
- Grant permissions or set a ceiling
- Identity policies: managed or inline
- Resource policies and service-specific rules
- Two ways across accounts
- Three questions to choose a policy
- When policies work together
- Common traps
- Question wording to policy choice
- Read the JSON, then replay the decision
- Self-check: predict, then explain
- Core terms and a debugging checklist
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 life | AWS meaning |
|---|---|
| Employee badge: what its holder may do | Identity-based policy |
| Guest list at a room: who may enter | Resource-based policy |
| Building rules: limits, not an entry ticket | Boundary, 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.
Explicit Deny?
A matching Deny in any applicable policy ends evaluation with explicit deny.
Organizations
Check resource-side RCPs and caller-side SCPs where applicable. They restrict grants; they do not create grants.
Resource grant
In the same account, a direct user or session grant may be sufficient. Role ARN grants still have boundary/session limits.
Identity and ceilings
For the identity-based path, find an Allow and check the attached boundary and any session policy.
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.
| Case | Change from baseline B | Decision |
|---|---|---|
| A | Remove the identity Allow | Implicit deny |
| B | Identity and boundary Allow s3:* | Allow |
| C | Boundary only allows s3:Get* | Implicit deny |
| D | Add SCP Deny s3:Delete* | Explicit deny |
| E | No identity grant; same-account bucket names the user ARN | Allow |
| F | Same as E, but move bucket to B | Implicit deny |
Deny and Organizations
No matching Deny; the Organizations ceiling permits this action.
Resource policy
No bucket policy grants the request.
Identity policy
There is no Allow. The boundary cannot fill the gap.
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.
Deny and Organizations
No matching Deny; applicable Organizations restrictions permit the request.
Identity policy
Allow s3:* covers s3:DeleteObject on the example resource.
Boundary
Allow s3:* also contains the requested action.
Allow
The identity grant survives the applicable ceilings.
4 / 4 · The identity grant survives the applicable ceilings. Sequence complete.
Identity policy
The same Allow s3:* grant is present.
Boundary
Only s3:Get* is allowed. s3:DeleteObject is outside that set.
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.
Request
ops-binh requests s3:DeleteObject.
SCP Deny
Deny s3:Delete* matches the action and example resource.
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.
Scope
User ops-binh and reports are both in A. No applicable explicit Deny or Organizations restriction blocks the action.
Bucket policy
Principal is arn:aws:iam::111122223333:user/ops-binh, with Allow s3:DeleteObject.
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.
Scope
ops-binh stays in A; reports is now in B.
Resource side
The bucket in B still grants the user access.
Caller side
The user in A still has no identity Allow for this request.
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.
Identity
Allow s3:*, ec2:* and iam:* initially covers GetObject, DeleteObject, RunInstances and CreateUser.
Boundary
Allow only s3:* and ec2:*. iam:CreateUser falls outside the boundary.
SCP
Deny ec2:* removes ec2:RunInstances. Its final classification is explicit deny, regardless of where it is drawn.
Session
A session policy allows only s3:Get*. s3:DeleteObject is outside this session.
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.
| Group | Attached to | Grants permissions? |
|---|---|---|
| Identity-based | User, group or role | Yes; no Principal element |
| Resource-based | Bucket, key, queue, role and supported resources | Yes; names a Principal |
| Permissions boundary | User or role | No; limits identity grants |
| SCP / RCP | Organizations root, OU or account | No; principal-side / resource-side guardrails |
| Session policy | STS session | No; narrows identity-based session permissions |
| ACL | S3 bucket or object | Coarse 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
| Type | Ownership | Reuse and lifecycle |
|---|---|---|
| AWS managed | AWS | Reusable; AWS can update it |
| Customer managed | Your account | Reusable; you manage changes |
| Inline | One identity | One-to-one; removed with its identity |
Before deletion
Analyst and Etl share managed policy ReportsRead. Analyst alone has inline policy AnalystTemp.
Remove attachments
Before API deletion, remove the inline policy and detach managed policies; satisfy any other DeleteRole requirements.
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
| Policy | Resource | Question it answers |
|---|---|---|
| Bucket policy | S3 bucket | Who may access these objects? |
| Key policy | KMS key | Who may use or administer this key, directly or through IAM delegation? |
| Trust policy | IAM role | Who may assume this role? |
| Queue / topic / function policy | SQS / SNS / Lambda | Which principal or service may call this resource? |
| Endpoint policy | VPC endpoint | Which 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.
Key policy
An applicable key-policy statement grants the account principal permission to delegate the requested operation through IAM.
IAM policy
Dev has Allow kms:Decrypt on this key. Delegation makes this IAM grant usable.
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.
Key policy
Only KeyAdmin is authorized. There is no applicable IAM delegation, direct Dev grant or KMS grant.
IAM policy
Dev has kms:* but that alone cannot authorize this key operation.
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
Account A
The caller identity policy allows s3:GetObject on the object ARN in B.
Account B
The bucket policy grants the caller access. Both sides pass applicable restrictions.
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.
Caller permission
A allows sts:AssumeRole on Role B.
Trust
Role B trusts the caller, and all trust conditions and applicable restrictions are satisfied.
STS credentials
The caller obtains temporary credentials for a Role B session.
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
- Grant or restrict? A new permission needs a grant. A limit needs a ceiling or an applicable Deny.
- Caller or resource? Identity policies belong to the caller; resource policies belong to the target.
- 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.
Intent
This is a new grant, not a new ceiling.
Resource owner
A owns the bucket, so A can grant DataReader access with its bucket policy.
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.
Intent
Restrict member-account principals, including root, rather than grant permissions.
Scope
Choose an SCP for the OU. It does not constrain the Organizations management account or service-linked roles.
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
| Need | Combination |
|---|---|
| Direct cross-account S3 | Caller identity + bucket policy |
| Assume a role in another account | Caller identity + target trust + target role permissions |
| Use a KMS key through IAM | Key-policy delegation + IAM grant |
| Delegate role creation safely | Conditional CreateRole grant + mandatory boundary + protection against removing it |
| Access through a VPC endpoint | IAM / resource authorization + endpoint restriction |
Request
Dev calls iam:CreateRole without PermissionsBoundary.
Condition
The only Allow requires iam:PermissionsBoundary to equal DevBoundary. The condition does not match.
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.
Request
Dev supplies the required DevBoundary ARN.
Condition
The conditional Allow matches, assuming every other requirement passes.
Created role
The role starts with its boundary. Identity policies attached later cannot exceed that boundary.
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
| Claim | Correction |
|---|---|
| SCP Allow grants S3 | It only permits the grant to survive that ceiling. |
| Any same-account resource Allow skips every ceiling | The exact user, role or session principal matters. |
| A more specific Allow defeats Deny | A matching explicit Deny wins. |
| An IAM group can be a bucket Principal | A group is not a request principal. |
| External ID is a secret password | It 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
| Requirement | Starting point |
|---|---|
| Restrict a member account or OU, including root | SCP |
| Let Dev create roles under a ceiling | Boundary + conditions and anti-removal controls |
| A third-party provider assumes a role | Trust policy + External ID condition |
| Limit access to organization members | Review aws:PrincipalOrgID in the resource policy |
| Permit only a VPC endpoint path | Review aws:SourceVpce and service-principal exceptions |
| Restrict requested regions | SCP 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"
}
}
}
]
}Action
ec2:RunInstances is not excluded by NotAction, so this statement covers it.
Resource
Resource * covers the example request.
Condition
us-east-1 differs from ap-southeast-1, so StringNotEquals is true.
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.
Action
iam:CreateRole matches the iam:* exception inside NotAction.
Not applicable
This Deny statement does not apply. It does not grant the action.
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
| Term | Meaning |
|---|---|
| Principal | The caller identity, account, session or AWS service; not an IAM group. |
| Implicit deny | No valid grant survives the applicable restrictions. |
| Explicit deny | An applicable Effect: Deny statement matches the request. |
| Condition | Context test such as source endpoint, organization, transport, tags or region. |
| ABAC | Attribute-based access control, often comparing principal and resource tags. |
| Role ARN / session ARN | Different 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.
Related posts
Attach AWS WAF in the right place and close the bypass
Where AWS WAF can attach, how ALB differs from NLB, body inspection limits and locking the origin, with six scenarios and config examples.
AWS acceleration: pick the right service for the slow leg
Six AWS acceleration services — CloudFront, Global Accelerator, S3TA, VPN, DAX, ENA/EFA — chosen by the slow leg, caching and protocol.
Speeding up EC2 and Lambda boot time
How to shorten Lambda cold starts and EC2 scale-out time with SnapStart, Provisioned Concurrency and warm pools, plus where each one stops working.
