Skip to main content
Welcome back — in this lesson we’ll cover a practical, reproducible approach to finding and fixing IAM permission issues across services, accounts, and CI/CD pipelines. Agenda
  • Common IAM issues and how to categorize them
  • Tools and workflows for policy debugging (Policy Simulator, CloudTrail, Access Analyzer, Access Advisor)
  • Policy evaluation order, boundaries, and resource policies
  • Automating policy validation in CI/CD
  • Cross-account and service-specific debugging tips
CloudTrail is essential: it records API calls (including failures), which you can correlate with Policy Simulator results and Access Analyzer findings to identify and remediate permission failures.
A flowchart titled "IAM Policy Debugging: Finding and Fixing Permission Issues" showing how an IAM policy is simulated with the Policy Simulator, analyzed by the IAM Access Analyzer, and checked against CloudTrail logs while CLI/SDK calls evaluate the policy. The diagram maps the workflow and tools used to find and fix permission failures.
Objective
  • Identify the effective principal (which identity or role made the request).
  • Inspect CloudTrail for denied API calls and request context.
  • Reproduce and simulate decisions with the IAM Policy Simulator.
  • Use Access Analyzer (and Access Advisor) to find overly broad permissions and unused privileges.
  • Iterate on policy fixes, retest, and automate validation in CI/CD.

S3: Example — simple read-only policy

Common scenario: grant read-only access to a bucket. Note the difference between permissions required to list a bucket and to read objects vs. permissions for writing objects.
Key points
  • s3:ListBucket applies to the bucket ARN: arn:aws:s3:::example-bucket.
  • s3:GetObject applies to object ARNs: arn:aws:s3:::example-bucket/*.
  • This policy does NOT allow s3:PutObject or other write operations.
If a developer gets AccessDenied pushing artifacts, use Policy Simulator + CloudTrail to determine which permission is missing. CI/CD permission errors (CodeCommit → CodeBuild → CodeDeploy) commonly block builds or deployments. S3 permission summary
A flowchart titled "The IAM Debugging Challenge" showing an AWS CI/CD pipeline from Developer to AWS CodeCommit, CodeBuild, CodeDeploy and EC2/ECS/Load Balancer. It also includes IAM troubleshooting components like IAM Policy Simulator, AWS Config, IAM Role and SCP enforcement for debugging permissions.

Common IAM issues — categories and examples

Most permission problems fall into three categories:
A presentation slide titled "Common IAM Policy Issues" showing three numbered categories: 1) Syntax and Structure, 2) Logical and Semantic, and 3) Context and Scope. Each category lists example problems such as "Invalid ARN," "JSON parse error," "Missing permission," "Explicit deny," "Missing context key," and "Wrong principal."

Policy evaluation order (practical mental model)

When AWS receives a request it evaluates all relevant policies and statements to reach a final decision:
  1. Request received.
  2. Identify applicable identity-based and resource-based policies (inline, managed, session policies).
  3. Evaluate conditions in matching statements.
  4. If any matching explicit Deny applies, the request is denied.
  5. Consider high-level controls: SCPs, permission boundaries, and service-specific restrictions.
  6. If no Deny blocks the request and at least one Allow applies, the request is allowed; otherwise it’s implicitly denied.
Explicit denies override any allow. A deny statement only applies when its conditions evaluate to true — always check the condition context when you see a deny.
A stepped flowchart titled "Policy Evaluation Flow" showing sequential boxes: Request Received → Identity-Based Policy → Resource-Based Policy → Context Conditions Checked → Explicit Deny Check → Final Decision. Arrows connect each step to indicate the order of the evaluation.

Policy Simulator and CloudTrail

  • IAM Policy Simulator: simulate which actions are allowed or denied for an identity or role before applying changes. Note: the simulator may not include account-level controls like SCPs, permission boundaries, or some service-specific checks — verify those separately.
  • CloudTrail: records actual API calls and errors. An AccessDenied CloudTrail entry contains the request context needed to reproduce and diagnose the issue.
Permissive policy example (for testing only):
Example CloudTrail-style event (abbreviated):
You can export CloudTrail logs to Amazon Athena for analysis or trigger automated responses with EventBridge. Use IAM Access Analyzer to detect overly permissive policies and feed findings into remediation pipelines.
A slide titled "IAM Access Analyzer: Proactive Permission Validation" comparing a "Before: Overly Permissive Policy" (wide access, cross-account access, no action restrictions) with an "After: Least Privilege Policy" (access limited to a specific S3 bucket, scoped to trusted accounts, and permissions restricted to required actions). Copyright KodeKloud appears at the bottom.

Reproducible debugging workflow

Follow a consistent process to reduce time-to-fix:
  1. Reproduce the issue (who, what, when, where).
  2. Identify the effective principal and review identity and resource policies.
  3. Use the Policy Simulator for the principal and action.
  4. Inspect CloudTrail for denied requests and full request context.
  5. Run Access Analyzer to identify overly broad grants and Access Advisor to find unused permissions.
  6. Apply a fix (manual or automated), retest, and add validation to CI/CD.
A flowchart titled "Debugging Workflow" that outlines troubleshooting steps (identify/reproduce issue, analyze policies, test with Policy Simulator, review CloudTrail logs) with decision diamonds labeled "Issue reproduced?" and "Missing permissions?". It’s a permission-debugging diagram credited to KodeKloud.
Access Advisor is useful to identify permissions that are not used and can be removed to converge on least privilege.
A slide titled "IAM Access Advisor: Finding Unused Permissions" showing a flow from a blue box reading "Regularly Review Unused Permissions" to an orange box reading "Incremental Permission Reduction." The slide is © KodeKloud.

Identity-based vs resource-based policies

  • Identity-based: attached to user, group, or role; define what the identity can do.
  • Resource-based: attached to the resource (S3 bucket policies, KMS key policies, Lambda resource policies, SQS policies); define who can access the resource.
Both can include conditions; a Deny in either will block access. Comparison table
A slide titled "Resource-Based Policy Debugging" showing a side-by-side table comparing identity-based and resource-based policies (e.g., attached to user/group/role vs resource like S3/KMS, what they specify, types, cross-account behavior, evaluation, and examples). It contrasts who policies are attached to and what they allow or deny.

Permission boundaries vs. Service Control Policies (SCPs)

  • Permission boundary: an IAM-level limit that constrains the maximum permissions an identity can obtain from identity-based policies.
  • SCP: an Organizations-level policy that sets the maximum permissions allowed for accounts/OUs in the organization.
Permission boundaries restrict what an identity can perform regardless of identity policies that grant more permissions. SCPs restrict what identities in an account can do across the organization. When debugging, check both if applicable.
A slide titled "Permission Boundary Debugging" showing a Venn diagram with two overlapping ovals labeled "Permission Boundary" (left) and "Identity Policies" (right), with the overlap marked "Effective Permissions (Intersection)". The image illustrates how effective permissions are the intersection of permission boundaries and identity policies.
When permission boundaries are present:
  • Compare the boundary policy with identity policies.
  • Temporarily modify boundaries for testing (in a controlled environment).
  • Analyze effective permissions as the intersection of boundary and identity policies.
  • Consider using service-specific boundary templates if available.
A vertical flowchart titled "Permission Boundary Debugging" that outlines steps from "Start" through comparing boundary vs identity policies, temporarily modifying boundaries for testing, analyzing effective permissions, and using service-specific templates, ending at "Issue Resolved."

Automating policy validation in CI/CD

Integrate policy validation into your pipeline to fail early when changes introduce overly permissive policies. Options:
  • CloudFormation/Linter checks (cfn-lint)
  • IAM Access Analyzer APIs (validation & findings)
  • AWS Config managed rules
  • Custom static analysis in build steps
A slide titled "Automating Policy Validation." It shows a CI/CD pipeline flow: Source → Build (CodeBuild) → Policy Validation (IAM Access Analyzer API / AWS Config Rules) → Test (Integration & Compliance) → Deploy (Production).
Example CodeBuild buildspec that installs a CloudFormation policy validator and runs it during the build phase:
Use this to validate IAM policies defined in CloudFormation templates before deployment.

Cross-account access debugging

Common cross-account failure points:
  1. The role trust policy in the target account does not allow the requesting account to assume the role.
  2. The principal in the requesting account lacks permission to call sts:AssumeRole.
  3. After assuming the role, the session’s effective permissions are insufficient due to missing identity/resource policies or boundaries.
Debugging steps:
  • Inspect the target role’s trust policy (who can assume it).
  • Verify the requesting principal has sts:AssumeRole.
  • Check for ExternalId or Condition mismatches.
  • Inspect resource policies and the assumed-session permissions.
A diagram titled "Debugging Cross-Account Access" showing two accounts (Account A: Trusted Account and Account B: Trusting Account) connected by a trust relationship and an IAM role with permission and resource-based policy issues labeled. It highlights common errors like "Trust Relationship Errors," "AssumeRole Permission Issues," and "Missing Resource Policies."
Checklist for cross-account validation:
  • Trust policy validation (who is trusted to assume the role).
  • Trace the access path end-to-end.
  • Validate any ExternalId usage.
  • Reproduce the AssumeRole call and inspect the resulting session policy.
A presentation slide titled "Debugging Cross-Account Access" that shows a "Checklist for Validating Cross-Account Access" with four numbered items: Trust policy validation, Step-by-step access path verification, External ID validation, and Session context troubleshooting. The slide uses colored tabs above each checklist card and is © KodeKloud.

Service-specific debugging tips

Common checks per service:
  • S3: bucket policy, ACLs, identity-based policy, and S3 Block Public Access settings.
  • Lambda: resource policy (who can invoke) and execution role (what the function can do at runtime).
  • DynamoDB: IAM identity policies and attribute-level permissions.
  • KMS: key policy, grants, and IAM policies.
A slide titled "Service-Specific IAM Debugging" showing AWS service icons (S3, Lambda, DynamoDB, KMS). Each icon has a short troubleshooting tip underneath (e.g., check path permissions/ACLs, execution role and resource policy).

Common CloudTrail AccessDenied events (examples)

Troubleshooting checklist (summary)

  • Reproduce the issue where possible.
  • Inspect CloudTrail for the exact API call and error context.
  • Simulate the action with IAM Policy Simulator.
  • Review identity-based and resource-based policies for:
    • Missing permissions
    • Wrong principals
    • Incorrect ARNs or conditions
    • Explicit denies
  • Check permission boundaries and SCPs when applicable.
  • For cross-account: validate the trust policy, then assume-role permissions, then session and resource policies.
  • Add policy validation into CI/CD pipelines to catch problems before deployment.
References and further reading Thanks for following this lesson — use the reproducible workflow and automation recommendations to reduce mean time to remediate IAM issues.

Watch Video