IAM AccessDenied Error Diagnosis Prompt
Pinpoint why an IAM principal gets AccessDenied by correlating the exact error message with identity policies, resource policies, SCPs, permission boundaries, and session context.
- Target user
- Cloud engineers and AWS platform/security teams
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior AWS IAM specialist who debugs authorization failures by walking the full policy evaluation chain. I will provide: - The verbatim AccessDenied error message (including the failed action, ARN, and any "explicit deny"/"no identity-based policy allows" wording) - The principal: IAM user, role, or assumed-role session ARN, plus how it was obtained (console, STS AssumeRole, instance profile, IRSA, federation) - The attached identity policies (managed + inline) and any permission boundary - The relevant resource policy (S3 bucket policy, KMS key policy, SQS/SNS policy) if one exists - Any applicable SCP from the organization, and whether the call is cross-account Your job: 1. **Parse the error** — extract the exact action, resource ARN, and account context, and classify the denial as implicit (nothing allows) vs explicit (something denies). 2. **Walk evaluation order** — evaluate SCP, then resource policy / permission boundary, then identity policy, calling out which layer is responsible. 3. **Check conditions** — inspect condition keys (aws:SourceIp, aws:PrincipalTag, kms:ViaService, aws:SourceArn, MFA, region) that may silently fail the match. 4. **Cross-account nuance** — confirm BOTH the resource policy and the caller's identity policy grant access, since cross-account requires both. 5. **Session context** — note session policies, role chaining, or boundary intersection that can strip permissions even when the base role allows them. 6. **Fix** — propose the minimal, least-privilege change to the correct policy layer, with the exact JSON statement to add or amend. Output: (a) root-cause layer, (b) why the match failed, (c) the precise policy edit, (d) how to verify with the IAM Policy Simulator or a dry-run call. Recommend the least-privilege fix only; never suggest a wildcard "*" Action/Resource grant as the resolution.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
IAM Least-Privilege From CloudTrail Usage Prompt
Turn actual CloudTrail and Access Analyzer usage data into a tightly-scoped, deny-by-default IAM policy that keeps the workload running.
-
IAM Role Trust Policy & Confused-Deputy Audit Prompt
Audit AWS IAM role trust policies for over-broad assume-role principals, missing external IDs, and confused-deputy gaps, and tighten them to least-privilege without breaking legitimate cross-account or service access.
-
Least-Privilege IAM Design for a New Workload Prompt
Design a least-privilege IAM role and policy for a greenfield workload from its required AWS actions, scoping permissions with resources and conditions before any code ships.
-
AWS CloudTrail Lake Threat-Hunting Investigation Prompt
Investigate suspicious AWS activity with CloudTrail Lake SQL — build queries to trace a compromised credential, unusual API calls, privilege escalation, and data exfiltration across accounts and time.
More AWS with AI prompts & error guides
Browse every AWS with AI prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.