Cloud IAM Lesson 4: Workload Identity
Table of Contents
Return to the Cloud IAM and Zero Trust Lab Course
A workload needs identity without a stored cloud key. Prefer platform identity or federation which exchanges trusted workload claims for short-lived access.
Choose the Pattern
| Pattern | Fit | Main risk |
|---|---|---|
| Platform-managed identity | Workload runs inside one cloud | Attached identity receives broad resource access |
| OIDC workload federation | CI/CD, Kubernetes, or external workload | Trust conditions accept unintended repositories, branches, or subjects |
| Service account with short-lived impersonation | Central workload identity model | Users or workloads impersonate a more privileged account |
| Static key or client secret | Legacy exception | Copy, leak, unclear owner, weak expiry, and difficult revocation |
Use static credentials only under a documented exception with owner, storage, rotation, monitoring, and retirement date.
Bind Trust Narrowly
Trust policy answers who gets a session. Permission policy answers what the session does.
For a CI workflow, bind trust to:
- Issuer: the approved identity provider
- Audience: the cloud token exchange endpoint or named application
- Subject: exact organization, repository, environment, branch, or service account
- Session duration: enough for one job
- Resource role: only required actions at the required scope
Avoid a wildcard subject covering every repository or branch. Review pull-request contexts separately from protected deployment environments.
Protect Service Accounts
Google Cloud guidance warns against automatic broad grants, service account keys, privileged impersonation paths, and project-wide service account access. The same review logic applies across providers.
Check these escalation paths:
- Who edits the workload’s trust policy?
- Who changes attached roles or bindings?
- Who impersonates the identity?
- Who deploys code under the identity?
- Which metadata or token endpoint exposes credentials?
- Which logs record token exchange and resource use?
Control-plane permission is often more sensitive than the workload’s current data permission. A principal able to rewrite policy might grant itself new access.
Practice Steps
Use the fictional payroll report build.
- Define the workflow issuer, audience, and subject.
- Set a sixty-minute maximum session.
- Grant read access to one report store.
- Exclude policy administration, identity administration, and write actions.
- Name the code owner and identity owner.
- Define token exchange and resource-access logs.
- Write a revocation test.
- Record the static key retirement date.
Expected Result: the workload receives a temporary session from exact claims and lacks policy administration rights.
Troubleshooting
| Problem | Fix |
|---|---|
| Federation accepts too many workflows | Narrow subject, audience, environment, and repository claims |
| The workload needs many services | Split identities by task and resource boundary |
| A key still exists after migration | Disable, monitor, remove, and verify rejected use through the approved process |
| Token exchange succeeds but access fails | Separate trust success from permission, scope, condition, and deny evaluation |
Verify Your Work
- No long-lived key is required in the target design
- Trust claims are exact
- Session duration is bounded
- Permission scope matches one task
- Policy editors and impersonators are reviewed
- Revocation has a test and evidence source
Primary reference, checked 2026-10-10: Google Cloud best practices for service accounts .
Next Steps
Continue to Lesson 5: Zero Trust Policy . Add resource, device, context, and telemetry to access decisions.


