One of the quickest, most concrete wins in IAMOps is replacing a stored cloud key in your build pipeline with a short-lived token that the pipeline earns on each run. This guide walks through the change step by step. You will need a pipeline that currently authenticates with a long-lived secret, access to your cloud account’s trust settings, and a test environment you are allowed to break.
Why bother
A stored secret can be copied, leaked or forgotten, and it stays valid until someone rotates it. In January 2023 a continuous-integration provider disclosed that an attacker had taken customer environment variables, keys and tokens, and the company advised customers to adopt OIDC tokens, which expire quickly. According to the relevant Atlas entry, moving critical pipelines to federation belongs in the first thirty days of any serious programme.
What you need before starting
- Read access to the pipeline definition and the identity it uses.
- Permission to create a trusted issuer and a role in your cloud account.
- A non-production environment where the pipeline can run without customer impact.
- Thirty to sixty quiet minutes, ideally paired with whoever owns the pipeline.
Step 1: List what the pipeline can do today
Open the policies attached to the identity your pipeline uses. Write one sentence per job: “deploy the web service”, “push container images”, “run database migrations”. Anything the policies allow beyond that list is surplus. Keep this list, because it becomes the new, narrower policy.
Step 2: Create the trust relationship
In your cloud account, register your CI provider as a trusted token issuer. Then create a role that the pipeline can assume only when its token carries the claims you specify. Do not attach any permissions yet. A role with a trust rule and no grants is safe to build while you work out the next steps.
Step 3: Write an exact subject condition
This is the line most people get wrong. The subject claim identifies which repository, branch or environment is asking. A pattern ending in a wildcard after the organisation name accepts every repository in the organisation, including those created tomorrow. Write the full subject for one repository and one environment, and create a separate role for production.
- Copy the subject string from a real pipeline run’s token, not from memory.
- Match it exactly, with no wildcard unless you can explain every possible value.
- Keep production and staging in different roles with different subjects.
Step 4: Attach only the permissions from your Step 1 list
Translate each sentence into specific actions and resources. Avoid the “allow everything except” pattern, because an Allow paired with a NotAction clause grants everything outside that list, which usually surprises people. If your platform offers an analyser that generates a starting policy from observed activity, use its draft as a head start, then read every line.
Step 5: Change the pipeline in a test branch
Add the token request to the job definition, switch the cloud login step to assume the new role, and delete the stored secret reference in that branch only. Run the pipeline. Expect at least one failure the first time; treat the error message as a to-do item, add the missing permission, and re-run. Keep a log of each addition so the final policy is explainable.
Step 6: Prove the refusals work
Run two negative tests. First, trigger the job from a different repository or branch and confirm the role refuses it. Second, try an action outside your list from within the pipeline and confirm it is denied. If either succeeds, your subject condition or policy is too loose. Fix it before moving on.
Step 7: Roll out, then revoke
Merge the change, watch two or three normal runs, then deactivate the old key rather than deleting it, so you can reverse quickly. After a week without incident, remove it. Record the date, the owner and the number of long-lived credentials you eliminated; that last figure is a metric worth tracking month over month.
Step 8: Repeat on the next pipeline
The Atlas ninety-day outline suggests federating half of your remaining pipelines by the end of the quarter. Order them by blast radius: whatever can reach production data goes first. If you want to think about the pipeline stage where such checks naturally sit, the article on early safety checks in delivery pipelines sets out the placement logic, and the broader roadmap for developers and security teams shows where this task fits in the overall plan.
Mistakes to expect along the way
A trust rule that omits a required claim may fail in confusing ways, and negated operators behave oddly when a claim is absent: a “not equal” test matches when the value is missing altogether, so a rule meant to exclude something may admit it. Prefer positive matches on exact values. Also watch for the pipeline that works in one branch and fails in another because the subject differs; that is the condition doing its job, not a bug.
Checklist before you close the ticket
- The stored secret is deactivated, with a removal date on the calendar.
- The role’s subject condition names one repository and one environment.
- Negative tests are saved in the repository and run on every policy change.
- An owner is named for the role and for the trust relationship.
Small, boring, repeatable. That is the whole appeal: each pipeline you federate removes a secret that could have leaked and teaches your team a pattern it can reuse.

