Short-lived federated credentials instead of stored secrets, and the root cause of token expiry on long applies
Every new repository gets Azure access through Entra ID workload identity federation, so each pipeline run receives a short-lived token instead of a stored client secret. I built this into the developer platform's onboarding. I also tracked down why long Terraform applies sometimes died partway through and left orphaned resources behind.
The federated credential's subject is scoped to repo:<org>/<repo>:environment:<env>, so only that environment's jobs can get that environment's access.
permissions:
id-token: write
contents: read
env:
ARM_USE_OIDC: "true"
ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
# Let the provider fetch fresh assertions itself via
# ACTIONS_ID_TOKEN_REQUEST_URL / _TOKEN. Don't export a one-off ARM_OIDC_TOKEN.
Applies longer than about 40 minutes (for example, managed database builds) failed with AADSTS700024: Client assertion is not within its valid time range. The next run then failed with "already exists, needs to be imported".
ARM_OIDC_TOKEN, and unset the request URL and token.terraform init. Standardise the source per pipeline.Keyless authentication removes a whole class of secret-management risk. Making it reliable for long-running infrastructure means understanding token lifetimes all the way down.
About this case study: this write-up is drawn from my hands-on platform engineering experience. Organisation names, system names, figures and timelines have been changed or generalised, and all code, configuration and queries are illustrative examples written for this page.