Introduction IAM role assumption failures (AccessDenied when calling AssumeRole) block cross-account access, CI/CD pipelines, and service-to-service authentication. The error message is generic, making it difficult to identify whether the issue is with the trust policy, IAM permissions, SCPs, or MFA requirements.

Symptoms - `aws sts assume-role` returns: `An error occurred (AccessDenied) when calling the AssumeRole operation` - Cross-account deployments fail at authentication step - ECS task role not assumed by containers - CodePipeline stuck at deployment stage with access errors

Common Causes - Trust policy does not include the calling principal - Calling principal lacks sts:AssumeRole permission - Organization SCP explicitly denies sts:AssumeRole - MFA required by role but not provided - External ID mismatch for third-party access

Step-by-Step Fix 1. **Check the role trust policy**: ```bash aws iam get-role --role-name MyRole --query 'Role.AssumeRolePolicyDocument' ``` Verify the Principal matches your user/role ARN.

  1. 1.Verify calling principal has sts:AssumeRole:
  2. 2.```bash
  3. 3.aws iam list-attached-user-policies --user-name my-user
  4. 4.aws iam get-policy-version --policy-arn <arn> --version-id v1
  5. 5.`
  6. 6.Check for SCP restrictions:
  7. 7.```bash
  8. 8.aws organizations list-policies --filter SERVICE_CONTROL_POLICY
  9. 9.aws organizations list-targets-for-policy --policy-id <scp-id>
  10. 10.`
  11. 11.Look for SCPs that deny sts:AssumeRole.
  12. 12.Assume role with MFA if required:
  13. 13.```bash
  14. 14.aws sts assume-role \
  15. 15.--role-arn arn:aws:iam::<account>:role/MyRole \
  16. 16.--role-session-name my-session \
  17. 17.--serial-number arn:aws:iam::<account>:mfa/my-user \
  18. 18.--token-code 123456
  19. 19.`

Prevention - Document all cross-account trust relationships in IaC - Use AWS IAM Access Analyzer to audit external access - Set up CloudTrail trails for sts:AssumeRole API calls - Avoid MFA requirements for service-to-service role assumptions - Use AWS SSO/Identity Center for centralized access management