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