Workload identity instead of static keys

A long-lived access key on a laptop or in a repository is a session that does not expire. A workload should assume a role for minutes, scoped to the API calls it actually makes.

Lesson 28 of 29 · 15 min read · practice only with authorization

Diagram

From a static key to a role that expires

Follow the path. One example at a time.

Step 1 of 4

Key

A static access key is created so a job or a laptop can call the cloud API.

Illustration: the job has a role, not a copied key
# The workload assumes a role for the calls it makes.
# A static access key is not sitting on the disk.
What changes the outcome
Secret

An access key and secret live in configuration.

Life

They work until someone remembers to delete them.

Scope

The policy is often broad because the key was for debugging.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

4 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. A key is a session

    What fails
    Static keys do not sit in front of a sign-in. There is no prompt, no device, and often no expiry. A copy is the account.
    Who is affected
    The owners of the data that policy can read, and whoever pays for what it can start.
    What you would notice
    A key older than your rotation policy, or a key in a repository secret scanner finding.
    What you change
    Replace it with workload identity. Revoke the key. Read the scanner page for the copy that already leaked.
  2. The role matches the job

    What fails
    A role that can administer the account, attached because a sample failed, is the key problem with a different name.
    Who is affected
    The same data owners, plus every other workload that can assume it.
    What you would notice
    A policy with a wildcard action, shared by the build and the production job.
    What you change
    Split roles. Name the actions. Give production a role the build cannot assume.
  3. Where credentials come from

    What fails
    Laptops should use the organization’s short-lived sign-in, not a key in a dotfile. CI should use the platform’s federation, not a secret variable copied from production.
    Who is affected
    The engineer who lost the laptop, and the repo that stored the file.
    What you would notice
    A setup document that begins by creating an access key.
    What you change
    Rewrite the document. Block key creation with a guardrail if your platform has one.
  4. What you alert on

    What fails
    Creation of a user access key, use of a key that should have been retired, and a role assumption from outside the account’s compute are the events.
    Who is affected
    The on-call person who finds out from a bill or a breach notice.
    What you would notice
    No trail on the identity events, or a trail nobody can search.
    What you change
    Turn the trail on before you need it. Page on new keys. Review assumptions for roles that can change other roles.

Static keys outlive the reason they were made

Cloud access keys are created to unblock a tutorial, a laptop, or a job, and they remain valid until a human deletes them. They are copied into environment files, CI variables, and chat. They do not go through the sign-in you just hardened with a passkey. Whoever has the key has the policy, from any network, at any hour.

Workload identity flips the default. The compute — a function, a virtual machine, a pipeline — assumes a role the platform will mint credentials for, for minutes. There is nothing to copy onto a laptop. If the job stops, the credential stops. That is the property you are buying. A key stored in a fancy secret manager is still a key.

The role is the blast radius

A short-lived credential for a role that can do everything is a short-lived disaster. Write the role from the API calls the job makes. Production data and the build system should not share it. Humans should not use the job’s role for debugging. Their sign-in can assume a read role for a short time, with a reason, if you need that, and that assumption should be logged.

You would notice keys older than your policy, a setup guide that creates one, a wildcard action, and a trail that does not record key creation. The people affected are the owners of the resources in the policy and the owner of the bill. The finding is the key and the role you will replace it with. Do not copy the secret into the ticket to prove it works.

Make the bad path loud

If the platform can deny user access keys at the organization, do that for production accounts. Where a key is unavoidable — a vendor that has not grown a federation option — isolate it, expire it, and give it a calendar owner. “Unavoidable” is a small list. Revisit it.

Alert when a key is created and when a retired key is used. The second alert means a copy you missed. The response is to disable it and find the copy, not to add the address to a story about hackers. Practice the assumption flow in a throwaway account with a budget alarm, which is the lab rule from the cloud chapter.

What you change

Inventory keys. Replace each one with a role or delete the workflow. Split build and production. Turn on the creation alert. Update the setup guide so the next person does not undo it. Pair this with the pull-request lesson: a role the build can assume should not be a role a fork’s code can use.

Read your provider’s current page on workload identity when you implement the assumption. The product names change. The property does not: minutes, not months, and a policy you can read aloud.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

A deploy job has used the same access key for eight months, and the key is also in a laptop dotfile. What failed?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapWorkload identity instead of static keysA long-lived access key on a laptop or in a repository is a session that does not expire.
  1. 01Pull requests from outside the trust boundaryCode from a fork or an untrusted branch is not your code yet.

Practice

  1. LabTenant deskTwo companies, one API. See what changes when the server checks ownership.

Glossary

  1. CardPublic object storageA bucket or blob container is world-readable or world-writable, so data leaks or is replaced.