liveBook · Manning

Two-key credential rotation

As explained in Effective Platform Engineering

Two-key credential rotation is a rotation pattern that maintains two simultaneously available credentials so one can remain valid while the other is replaced.

Two-key credential rotation keeps a service account’s previous credential valid while a replacement becomes available. This prevents an in-progress pipeline from failing when the credential in the secrets store changes. section 6.4.4

For an automated rotation:

  • Maintain two valid keys, but put only the latest credential in the secrets store for newly launched jobs to fetch. section 6.4.4
  • Keep the prior key valid until the next rotation so jobs already using it can finish. section 6.4.4
  • Choose the interval with both keys in mind: rotating every seven days keeps the active key at most seven days old and rotates both keys within fourteen days. section 6.4.4
Figure 6.19 Our service account has two valid credentials at any given time. Only the latest credential is maintained in the secrets store, and the prior keys remain valid until the next rotation to prevent workloads and orchestration from failing due to the race condition of the key being changed while a job is already in process.
A screenshot of a computer

AI-generated content may be incorrect.

The diagram shows why the secrets store holds the newest credential while the previous key remains usable by work already in progress. section 6.4.4

How Effective Platform Engineering covers it

How deep it goes
Explains the overlap and seven-day rotation example, then points to an automated tool rather than detailing its implementation.
Examples
Uses a seven-day rotation schedule and an iam-credential-rotation command targeting PlatformServiceAccounts.
What it assumes
Assumes familiarity with IAM users, pipelines, and secrets stores while explaining the two-key timing pattern.
What you can do after
Apply it via iam-credential-rotation to renew IAM service-account keys without immediately invalidating credentials held by running jobs.
How it connects
Links IAM users, service accounts, secrets stores, and automated pipelines.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Platform Engineering. The section links point to the parts of the book it draws on.