Sub topic 14
Debugging AccessDenied with the policy simulator and CloudTrail
This chapter assumes you know the evaluation rule (default deny, explicit deny wins, otherwise at least one allow). It also assumes you can read an IAM policy in JSON. You will use these tools to find which policy causes an unexpected AccessDenied.
Start with the error message
Many AWS services say which kind of policy caused the denial. Read the message before you open any console.
| Message wording | What it points to |
|---|---|
| "no identity-based policy allows the action" | Implicit deny. The principal's identity policies have no matching Allow. |
| "with an explicit deny in an identity-based policy" | A Deny statement in a policy attached to the principal. |
| "with an explicit deny in a resource-based policy" | A Deny in the bucket policy or similar. |
| "with an explicit deny in a service control policy" | An SCP blocks the action. |
| "no permissions boundary allows the action" | The boundary does not include the action. |
Not every service gives this detail. When it does not, work through the checklist below.
The checklist
Check the layers in this order. Each step answers one question.
- Is the request what you think it is? Confirm the caller, the action, and the resource ARN. A common mistake is that an application uses a different role than you expected.
- Is there an explicit deny? Look in identity policies, the resource policy, permission boundaries, session policies, and SCPs. One matching Deny ends the search.
- Do the guardrails allow it? An SCP, permission boundary, or session policy must each contain a matching Allow, or the request is denied.
- Does a grant exist? In one account, an identity policy or a resource policy must allow it. Across accounts, both sides must allow it.
- Do the conditions match? A condition such as
aws:SecureTransportoraws:SourceIpcan make an Allow not apply.
Find the caller with CloudTrail
CloudTrail records API calls. A failed call appears as an event with an errorCode such as AccessDenied. Open the event and check three fields:
userIdentity: shows the principal. For a role session, check thearnand thesessionContext.eventNameandrequestParameters: show the exact action and resource.errorMessage: often repeats the denial reason.
This tells you whether you are debugging the right principal and the right ARN. Many "mystery" denials turn out to be the wrong role or a typo in the resource.
Test with the policy simulator
The IAM policy simulator evaluates policies without making the real call. For a role, it uses the identity policies and the permission boundary attached to it.
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/ReportWriter \
--action-names s3:GetObject s3:PutObject \
--resource-arns arn:aws:s3:::example-reports-bucket/2026/summary.csvFor each action, the output has an EvalDecision of allowed, implicitDeny, or explicitDeny. The MatchedStatements list shows which policy and statement decided the result.
Read the decision like this:
implicitDenymeans no policy allowed the action. Add an Allow, or check whether a boundary hides the existing one.explicitDenymeans a Deny matched. UseMatchedStatementsto find it.allowedfor the identity side, while the real call fails, means the problem is elsewhere. Look at the resource policy, an SCP, a session policy, or conditions.
A worked example
A role ReportWriter has an identity policy allowing s3:* on the bucket. A boundary allows only s3:GetObject and s3:PutObject. A user reports that s3:DeleteObject fails.
Simulating s3:DeleteObject returns implicitDeny. The identity policy allows it, so the cause must be a layer that does not. The boundary has no matching Allow for delete. The fix is to decide whether the role should delete at all. If it should, change the boundary. Adding more identity permissions changes nothing, because the boundary caps them.
Exercise
The simulator reports allowed for s3:GetObject on a role, but the real call returns AccessDenied, and the error message mentions a service control policy. What do you check next, and why did the simulator not show the problem?
Show answer
Check the SCPs on the account and its organizational units for a Deny or a missing Allow covering s3:GetObject. The simulator evaluated only the policies attached to the role, so it did not account for the organization-level guardrail that actually blocked the request.