Troubleshooting Access Denied Errors Methodically
This lesson sets out a methodical approach that finds the policy blocking a request quickly, since authorisation failures are common in practice and in exam questions.
Learning outcomes
After completing this lesson, you will be able to:
- Interpret the reason given in an AccessDenied message.
- Describe the order in which the possible causes are checked.
- Recognise encryption and cross-account traps.
- Use the policy simulator and decode encoded authorisation messages.
Read the error first
Many AccessDenied messages give the reason: "explicit deny in a service control policy", "no identity-based policy allows", "explicit deny in a resource-based policy", "no session policy allows". CloudTrail shows the call, the principal (with session) and errorCode.
Check in order
An unexpected access denial can be diagnosed by checking a sequence of possible causes. The checks should be made in the following order.
- Explicit denies anywhere: identity, resource, SCP, RCP, boundary, session and VPC endpoint policies.
- An allow exists for the exact action and ARN: watch typos, wrong Region or account, bucket vs object ARNs.
- Conditions: Region, tags, MFA, source IP or endpoint, encryption headers,
aws:SecureTransport.
The following diagram follows the decoding of an EC2 UnauthorizedOperation error to its fix.

Finding the blocking policy
Encryption and cross-account traps
Encryption and cross-account access introduce additional requirements that are commonly overlooked
- SSE-KMS objects and encrypted volumes also need
kms:Decrypt/kms:GenerateDataKeyin both the key policy and IAM; a missing KMS permission often looks like an S3 denial. - Across accounts, both sides must allow; for roles, the trust policy must allow the caller and the caller needs
sts:AssumeRole.
Hidden causes of denials
Tools
Three IAM tools help diagnose Access Denied errors. The IAM policy simulator tests whether a principal's identity policies, permissions boundary and the effect of SCPs allow particular actions on particular resources, and shows which statement allowed or denied each one. Access Analyzer policy validation finds mistakes in a policy, such as an invalid action or a condition key that does not apply. Last accessed data shows which services and actions a principal has actually used, which helps decide what is genuinely needed when removing permissions. The error message itself often names the type of policy that denied the request. The following table summarises the tools.
| Tool | Use |
|---|---|
| IAM policy simulator | Test identity policies, boundaries and SCP effect against actions and resources |
| Access Analyzer policy validation | Find mistakes |
| Last accessed data | What is actually used |
Tools for access problems
Decoding an EC2 authorisation failure
An automation role fails to launch instances with UnauthorizedOperation and an encoded message. Decoding it (the caller needs sts:DecodeAuthorizationMessage) reveals which check failed:
aws sts decode-authorization-message --encoded-message "$ENCODED" \
--query DecodedMessage --output text | jq '{allowed, explicitDeny, matchedStatements: .matchedStatements.items, context: .context.conditions}'The output shows explicitDeny: true with a matched statement from an SCP named RequireIMDSv2AtLaunch, and the request context shows ec2:MetadataHttpTokens = optional. The fix is in the launch template (set HttpTokens=required), not in the role's IAM policy: adding permissions to the role could never override an explicit deny in an SCP.
How can policies be tested before they are deployed?
Show answer
With the IAM policy simulator.
Exam Tips
Remember for the exam
- When access to an encrypted S3 object is denied, check the KMS key policy and kms:Decrypt.
- When IAM allows an action but it is still denied, look for an SCP, RCP, boundary, endpoint policy or explicit deny.
- To test policies before deploying them, use the IAM policy simulator.
- When the error says "explicit deny in a service control policy", fix the SCP, not the role.
- Across accounts, check both the caller's policy and the resource or trust policy.