Opscraft
AWS IAM & multi-account security · Lesson 1 of 7 · 3 min read

Identities and credentials

IAM is the most-asked AWS security topic in DevOps interviews, and the one where vague answers are easiest to spot. A senior engineer must be able to read and write policies, explain how AWS evaluates them, set up roles for CI and Kubernetes workloads without long-lived keys, design a multi-account organisation with guardrails, and investigate an access-denied error or a leaked key methodically.

Principals

Enlarge diagramPeopleIdentityCenter SSO +MFA → a roleper accountWorkloadsroles:instanceprofile, IRSA,task roleCI/CDOIDCfederation →a deploy roleIAM userswith keysavoid:long-lived,leak easilyRoot userlock away;MFA;break-glassonly
Figure 1. Who can call AWS. Humans sign in through Identity Center; workloads use roles. Long-lived IAM user keys are the exception, not the rule.
Swipe sideways to see all of it, or tap to open it full screen.
Principal What it is Credentials
Root user Owner of the account; unrestricted Lock away: MFA, no access keys, use only for the few root-only tasks
IAM user Long-lived identity Password and/or access keys — avoid for humans and machines in modern setups
IAM group Collection of users for attaching policies Not a principal itself
IAM role Identity assumed by trusted principals; no long-term credentials Temporary credentials from STS (access key, secret, session token)
Federated users Workforce identities from an IdP via IAM Identity Center (SSO) or SAML/OIDC Temporary role sessions
Service principals AWS services (ec2.amazonaws.com, lambda.amazonaws.com) assuming roles Temporary

Principle: humans use IAM Identity Center (SSO with MFA, permission sets mapped to roles in each account); workloads use roles (instance profiles, IRSA/Pod Identity, Lambda execution roles, OIDC from CI). Access keys are the exception and should be rotated, scoped and monitored.

STS and role assumption

  • AssumeRole — a principal with permission assumes a role whose trust policy allows it; returns credentials valid 15 minutes to the role's max session duration (1–12 hours; role chaining is capped at 1 hour).
  • AssumeRoleWithWebIdentity — OIDC tokens (GitHub Actions, EKS IRSA).
  • AssumeRoleWithSAML — SAML federation.
  • GetCallerIdentity — "who am I?" — always works, the first debugging command.
aws sts get-caller-identity
aws sts assume-role --role-arn arn:aws:iam::222233334444:role/deploy \
  --role-session-name alice-debug --duration-seconds 3600

Credential provider chain (SDK/CLI) order, roughly: explicit parameters → environment variables → web identity token file (IRSA) → shared config/credentials files (profiles, SSO) → container credentials (ECS task role, EKS Pod Identity) → EC2 instance metadata (IMDS). Knowing this explains "why is my pod using the node role?" — the web identity variables or Pod Identity agent weren't injected, so it fell through to IMDS.

Enlarge diagramCalleruser, role or OIDC tokenSTSRole "deploy"trust + permission policiesAssumeRole (deploy)trust policy: is this caller allowed?yestemporary keys + token, 15 min to 12 hcalls AWS with therole's permissions
Figure 2. Assuming a role: the trust policy decides who may assume it, the permission policy decides what it can do, and STS hands out temporary credentials.
Swipe sideways to see all of it, or tap to open it full screen.