Identities and Principals
Who and what acts in your cloud
IAM starts with principals: users, groups, roles and service identities. Who or what can act in your cloud, and how they prove who they are, is the identity layer everything else hangs on.
What you will learn
- Distinguish users, groups, roles and service identities
- Explain principals per cloud (AWS IAM, Entra ID, GCP IAM)
- Design identity that separates humans from machines
A principal is any entity that can make an API call: users (humans), groups (collections), roles (assumable), and service identities (machines, service accounts, managed identities). Identity proves 'who' before policies decide 'what'.
What is this?
IAM identity: AWS has IAM users, groups, roles, and instance profiles; Azure has Microsoft Entra ID users/groups, service principals and managed identities; GCP has Google identities, IAM service accounts, and workload identity. Principals carry credentials (password, keys, tokens) and are mapped to policies that authorize actions. Design separates humans (long-lived but MFA-gated) from machines (short-lived, scoped tokens).
Why do you need it?
- Nearly every 'who has access to what' question is an identity question.
- Federated/SSO identity centralizes onboarding and offboarding ({ha {the} ex-employee problem}).
- Machine identities scale past humans: CI pipelines, services, Lambda/containers need them.
- Blast radius shrinks when identities are least-privilege and scoped.
Mental model
Building badges: staff badge, visitor badge, and a robot badge
IAM identities
Staff (users) have a badge with photo (MFA). Visitors (roles) are issued a temporary pass at the desk. Robots (service accounts) get a badge that opens only the doors their machine needs. All prove who/what is at the door before the door decides.
How it works
- AWS: IAM user (person/access), IAM role (assumed by users/services/cross-account), instance profile (role for EC2/ECS).
- Azure: Entra ID users/groups; service principals are the app identity; managed identities are system-assigned/service-assigned identities Azure rotates.
- GCP: every Google account is an identity; IAM service accounts are machine identities (key-protected); workload identity federation for cross-cloud.
- Credentials prove identity: user password/MFA, access keys, OIDC tokens, x509 keys for GCP SAs.
- Policies attach to principals (identity-based) or resources (resource-based); both are evaluated.
Identity layer.
In production
- A company centralizes SSO via Entra ID with MFA and auto-deprovisions users from SAML to AWS.
- CI pipelines run with OIDC/workload identity — no long-lived keys in config.
- An EC2 fleet uses instance profiles so code never stores credentials.
Best practices
- Humans: federated SSO + MFA; machines: scoped service identities with rotating tokens.
- Use groups, not per-user grants, so lifecycle is managed once.
- Deprovision fast: offboarding an identity also kills its tokens.
- Audit identities: list users/service accounts with keys yearly, remove stale ones.
Common mistakes
- Hardcoding a long-lived access key in a Lambda environment variable.
- Everyone in one 'admins' group with broad powers.
- Sharing an IAM user across teammates (no audit trail per person).
- Service accounts given Owner/Editor forever.
Common issues
CI can't deploy but prod logs show allowCI uses a different (deleted or scoped) service account
Confirm the OIDC subject/role mapping and the credential's scopes.
New hire can't see the dev consoleUser not added to the right group or SSO not propagated
Add to the group and wait for directory sync/provisioning.
Service key leaked in a repoKey stored in source control
Rotate immediately, scan the repo, switch to workload identity/OIDC.
Debugging tips
- Who caused that change? Check audit logs (CloudTrail, activity log) keyed by principal/name.
- Permission denied? Verify the identity's effective policy and the credential being used.
- Machine loops: confirm the service account has the exact actions the workflow needs.
- For federated users, trace the IdP session and the mapped role.
Interview checkpoint
Hands-on lab
- Enumerate users, groups and service identities for a small org
- Decide which credential strategy fits each
- Produce an audit-friendly matrix
Model an Identity Matrix Locally
25 min · beginner
Quick quiz
Which of the following is a machine identity?
Groups let you manage entitlements for many users at once.