SkillSprout
Chapter 4 · Lesson 1
Intermediate
7 min read

IAM Operations and Access Troubleshooting

Overview

Day-to-day IAM work is mostly answering "why is this access denied?" and keeping permissions tight over time. To do either you need a clear mental model of how AWS evaluates a request: it gathers every applicable policy, looks for an explicit deny, and then for an allow.

Imagine a nightclub door. The bouncer first checks the ban list (explicit deny), then the venue's capacity rules (SCPs, permission boundaries, session policies), and only then looks for your name on the guest list (identity or resource policy). Miss any step and you are not getting in.

SysOps administrators also run the hygiene tasks: credential reports, unused access, MFA enforcement, key rotation and cross-account roles. Tools like IAM Access Analyzer, Access Advisor and the Policy Simulator make this manageable.

Key Concepts

  • Evaluation logic: default deny -> any explicit Deny wins -> SCPs/permission boundaries/session policies must allow -> identity or resource-based policy must allow.
  • Within one account, a resource-based policy that names the principal can grant access even without an identity policy; cross-account needs both sides to allow.
  • Roles and STS: temporary credentials via AssumeRole; the trust policy says who may assume, the permissions policy says what they can do.
  • Permission boundaries cap the maximum permissions of a user/role; they never grant on their own.
  • IAM Access Analyzer finds resources shared externally, validates policies and generates least-privilege policies from CloudTrail; also flags unused access.
  • Credential report (account-wide CSV) and Access Advisor (last-used per service) support clean-up and audits.
  • IAM Identity Center (successor to SSO) centralises workforce access with permission sets across accounts.
  • Secure the root user: MFA, no access keys, use only for tasks that require it.

Detailed Notes

Policy types and their effect

Policy typeGrants permissions?Notes
Identity-based (user, group, role)YesMost common
Resource-based (S3, SQS, KMS, role trust)YesCan allow cross-account principals
Permission boundaryNo (limits)Max permissions for an identity
SCP (Organizations)No (limits)Applies to all principals in member accounts, not the management account
Session policyNo (limits)Passed during AssumeRole / federation
RCP (resource control policy)No (limits)Organization-wide guardrail on resources

Troubleshooting AccessDenied step by step

  1. Read the error message; newer messages say which policy type denied (e.g. "with an explicit deny in a service control policy").
  2. Decode authorisation failures with aws sts decode-authorization-message.
  3. Check CloudTrail for the event: errorCode: AccessDenied, principal ARN, requestParameters.
  4. Use the Policy Simulator to test actions.
  5. Review conditions: aws:SourceIp, aws:MultiFactorAuthPresent, aws:RequestedRegion, tags, VPC endpoint (aws:SourceVpce).
  6. For S3/KMS also check bucket policy, Block Public Access, KMS key policy and grants.
bash
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::111122223333:role/app \
  --action-names s3:GetObject --resource-arns arn:aws:s3:::data-bucket/report.csv
aws sts decode-authorization-message --encoded-message <BLOB>

Assume role across accounts

Trust policy in the target account:

json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "AWS": "arn:aws:iam::111122223333:role/ops-admin" },
    "Action": "sts:AssumeRole",
    "Condition": { "Bool": { "aws:MultiFactorAuthPresent": "true" } }
  }]
}
bash
aws sts assume-role --role-arn arn:aws:iam::999988887777:role/ReadOnly \
  --role-session-name audit --duration-seconds 3600

The caller also needs sts:AssumeRole permission in its own identity policy.

Enforcing MFA for sensitive calls

json
{
  "Effect": "Deny",
  "Action": ["ec2:StopInstances", "ec2:TerminateInstances"],
  "Resource": "*",
  "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } }
}

Hygiene and audits

bash
aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 -d > report.csv
aws iam generate-service-last-accessed-details --arn arn:aws:iam::111122223333:user/dev
aws accessanalyzer list-findings --analyzer-arn <ARN> --filter 'status={eq=ACTIVE}'
TaskTool
Which keys are older than 90 days / no MFA?Credential report
Which services does a role never use?Access Advisor / unused access analyzer
Is a bucket/role shared outside the org?Access Analyzer external access findings
Build least privilege from activityAccess Analyzer policy generation
Test before deploymentPolicy Simulator / policy validation

Key rotation procedure

  1. Create second access key; update application.
  2. Verify the old key shows no recent use (get-access-key-last-used).
  3. Set old key Inactive, wait, then delete. Prefer roles (EC2 instance profiles, ECS task roles, Lambda execution roles, IRSA) over long-term keys.

Common pitfalls

SymptomCause
Role works in console but not for LambdaTrust policy lacks lambda.amazonaws.com
Can assume role but cannot use S3Missing permissions or an SCP/boundary
iam:PassRole AccessDeniedCaller must have PassRole on the role being passed (with condition on service)
Cross-account S3 access deniedBucket policy allows but caller's identity policy does not (or object owned by another account)
Condition keys never matchCase sensitivity, missing IfExists, tag key typos

Evaluation order: explicit deny anywhere wins; otherwise an allow is needed from identity policy and (where present) resource policy, and must not be blocked by SCPs, permissions boundaries or session policies. Same-account resource policies can grant access alone; cross-account needs both sides.

ToolUse
IAM Access AnalyzerFinds external access (public S3, cross-account roles), unused access, and validates policies
Credential report / access advisorFinds stale keys and unused services to trim permissions
Policy SimulatorTests what a principal can do
Permissions boundaryCaps maximum permissions of a role/user
IAM Identity CenterCentral SSO to many accounts with permission sets
STS decode-authorization-messageReveals why a request was denied
bash
aws iam generate-credential-report && aws iam get-credential-report --query Content --output text | base64 -d
aws sts decode-authorization-message --encoded-message <message>
aws accessanalyzer list-findings --analyzer-arn <arn> --filter '{"status":{"eq":["ACTIVE"]}}'
aws iam get-account-password-policy

Prefer roles with temporary credentials over long-lived keys, require MFA for privileged actions with aws:MultiFactorAuthPresent, and use ExternalId for third-party cross-account roles. Reduce the root user to emergency use with MFA and no access keys.

Real World Example

Scenario – locked out of a deployment. A CI pipeline role suddenly fails with AccessDenied on ec2:RunInstances. The engineer finds the CloudTrail event, decodes the authorisation message and sees "explicit deny in a service control policy". The security team had just rolled out an SCP restricting Regions with aws:RequestedRegion; the pipeline targeted a Region not on the allow-list.

The fix is to deploy to an approved Region (or add a justified exemption), and the team adds the SCP check to their runbook. Separately, a monthly Access Analyzer unused-access report removes 120 stale permissions.

Architecture Diagram

IAM authorisation decision
Architecture
AWS account
Principalrole session
Explicit deny?any policy
SCP / boundarymust allow
Identity / resource policymust allow
Allowed
  1. 1A principal sends an authenticated request.
  2. 2AWS checks all policies for an explicit deny; any match ends the evaluation.
  3. 3Guardrails (SCP, permission boundary, session policy) must allow the action.
  4. 4An identity or resource policy must grant it; otherwise the implicit deny applies.

Best Practices

  • ✓Use roles and temporary credentials; rotate or remove long-term access keys.
  • ✓Enforce MFA for humans and protect the root user (MFA, no keys, alerts on use).
  • ✓Run Access Analyzer (external and unused access) and review the credential report regularly.
  • ✓Apply least privilege with conditions (Region, tags, source VPC endpoint, MFA).
  • ✓Centralise workforce access with IAM Identity Center and permission sets.

Common Interview Questions

Exam Tips

SOA-C03 focus

  • Explicit Deny always wins; SCPs and boundaries only limit.
  • Instance needs AWS access -> instance profile role, never stored keys.
  • Who in the account has old keys or no MFA -> credential report.
  • Find external sharing of buckets/roles/KMS keys -> IAM Access Analyzer.

Finished this lesson?

0 of 46 lessons done · 0% of the course