- 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

- 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.s3:ListBucketapplies to the bucket ARN:arn:aws:s3:::example-bucket.s3:GetObjectapplies to object ARNs:arn:aws:s3:::example-bucket/*.- This policy does NOT allow
s3:PutObjector other write operations.

Common IAM issues — categories and examples
Most permission problems fall into three categories:
Policy evaluation order (practical mental model)
When AWS receives a request it evaluates all relevant policies and statements to reach a final decision:- Request received.
- Identify applicable identity-based and resource-based policies (inline, managed, session policies).
- Evaluate conditions in matching statements.
- If any matching explicit
Denyapplies, the request is denied. - Consider high-level controls: SCPs, permission boundaries, and service-specific restrictions.
- If no
Denyblocks the request and at least oneAllowapplies, 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.

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.

Reproducible debugging workflow
Follow a consistent process to reduce time-to-fix:- Reproduce the issue (who, what, when, where).
- Identify the effective principal and review identity and resource policies.
- Use the Policy Simulator for the principal and action.
- Inspect CloudTrail for denied requests and full request context.
- Run Access Analyzer to identify overly broad grants and Access Advisor to find unused permissions.
- Apply a fix (manual or automated), retest, and add validation to CI/CD.


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.
Deny in either will block access.
Comparison table

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.

- 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.

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

Cross-account access debugging
Common cross-account failure points:- The role trust policy in the target account does not allow the requesting account to assume the role.
- The principal in the requesting account lacks permission to call
sts:AssumeRole. - After assuming the role, the session’s effective permissions are insufficient due to missing identity/resource policies or boundaries.
- Inspect the target role’s trust policy (who can assume it).
- Verify the requesting principal has
sts:AssumeRole. - Check for
ExternalIdorConditionmismatches. - Inspect resource policies and the assumed-session permissions.

- Trust policy validation (who is trusted to assume the role).
- Trace the access path end-to-end.
- Validate any
ExternalIdusage. - Reproduce the AssumeRole call and inspect the resulting session policy.

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.

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.