Secrets rotation lab
Define the service boundary and ship target
Ship a falsifiable slice of **answer API + indexer sharing provider key via versioned secrets manager** — success is rotate to v2 → deploy → traffic on v2 → revoke v1 with audit event ROT-2026-07-30, not a polished screenshot.
1Try it yourself
Decision drill
Secrets rotation lab
Revoke leaked keys, rotate on schedule, audit access.
1/3API key found in a public gist.
2Learn the idea
Read
Name the operable slice
This lab builds answer API + indexer sharing provider key via versioned secrets manager. The human in the loop is security engineer rotating openai/prod after contractor offboarding. Scope is intentionally narrower than “make AI reliable”: you will prove one oracle — rotate to v2 → deploy → traffic on v2 → revoke v1 with audit event ROT-2026-07-30 — and one invariant — dual-key window: readers accept v1+v2; revoke v1 only after emit proves zero v1 use for 30m. Record non-goals in your notes so a later change cannot silently expand authority. The incident mnemonic for the chapter is SEC-REVOKE-EARLY-21; design as if that ticket is already written and you are filling evidence.
Read
Write the acceptance contract
Turn the oracle into a table: input fixture, expected observable, prohibited side effect, owner, latency/cost ceiling. Separate model taste from software correctness — transport, auth, parsing, and termination must be deterministic even when generated text varies. Primary metric family: secret_version_share and auth_fail_rate. Averages without a denominator or revision label do not gate release. Fake external dependencies in unit tests; live calls wait until fakes pass.
Read
Implementation artifact
secret: openai/prod
versions: [v1, v2]
dual_read_minutes: 30
Read
Freeze the first red test
Before implementation, encode a failing check that would have caught revoke v1 while indexer still cached v1 → 401 storm. That failure is the pedagogical north star for later pages: contracts reject it, happy path never performs it, validation asserts it, failure-handling contains it, observability detects it, security-ops prevents privilege tricks around it, and mastery replays it in a drill. Endpoint under study: secrets manager path openai/prod.
Read
Stage depth
Capacity note for planners: estimate peak demand on secrets manager path openai/prod and the cost ceiling for a failed retry storm. Write the abort conditions — unbounded spend, cross-tenant leakage, or inability to roll back — before you enjoy the first green test. Prefer synthetic fixtures shaped like production over anonymized production dumps you cannot share in class. When you are tempted to widen scope, re-read the oracle (rotate to v2 → deploy → traffic on v2 → revoke v1 with audit event ROT-2026-07-30) and cut features that do not serve it. The teaching outcome is judgment under constraints: security engineer rotating openai/prod after contractor offboarding gets a trustworthy control, not a kitchen-sink framework. Keep the language of release decisions: promote, hold, or roll back — never “see if it gets better.”
Read
Field notes for `secrets-rotation-lab` / `lab-goal`
Decide what will live in version control on day one: fixtures, contract markdown, and a failing test name. Write the cost ceiling as a hard number with currency and period. If the lab involves clusters, name the non-prod context you will use and forbid prod kubecontexts in scripts. Capture the baseline metric once before changing code so later gains are comparative. Refuse tools that hide the request path behind magic macros until the oracle is green on fakes. Your README section for this page should be five lines or fewer and still falsifiable. In this chapter the product is answer API + indexer sharing provider key via versioned secrets manager, the human stakeholder is security engineer rotating openai/prod after contractor offboarding, and the incident id you design against is SEC-REVOKE-EARLY-21. Re-state the oracle in your notes — rotate to v2 → deploy → traffic on v2 → revoke v1 with audit event ROT-2026-07-30 — and keep the invariant visible: dual-key window: readers accept v1+v2; revoke v1 only after emit proves zero v1 use for 30m. Track secret_version_share and auth_fail_rate as the scoreboard. Surface under change control: secrets manager path openai/prod.
Go deeper
Before you start
Why this matters
Write the single done-definition a reviewer would accept for Secrets rotation lab (SEC-REVOKE-EARLY-21). Include the numeric gate hidden in this oracle: rotate to v2 → deploy → traffic on v2 → revoke v1 with audit event ROT-2026-07-30. Then name the fake success you refuse: a demo that ignores revoke v1 while indexer still cached v1 → 401 storm. Keep the sentence beside your editor; every later page should make this sentence easier to prove.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.