Secrets rotation and incident readiness
Prerequisite: node-permissions-and-isolation. Objective: Review rotation runbook. Each example is independent. Use Node.js 22.16.0 in a disposable directory; save as main.mjs and run node main.mjs. No external service is contacted.
How it works
For routine rotation, identify consumers, provision a new credential through the authorized secret manager, deploy updated consumers, verify them and retire the old credential. When compromise is suspected, immediate revocation may take priority over availability. Never record actual secret values in logs or source control. Track credential identifiers, ownership and status rather than secret material. The examples are state models, not secret-manager operations.
Gate routine retirement
function retire(consumers){return consumers.length>0&&consumers.every(c=>c.newVerified===true);}console.log(retire([{newVerified:true},{newVerified:false}]),retire([{newVerified:true}]));Expected output:
false trueAll known consumers must be verified before routine retirement.
Separate identifiers from sensitive values
const event={credentialId:'catalog-v2',status:'verified',secret:'fictional-unused'};const audit={credentialId:event.credentialId,status:event.status};console.log(JSON.stringify(audit));Expected output:
{"credentialId":"catalog-v2","status":"verified"}An explicit audit projection omits the synthetic secret field.
Common mistake
Do not preserve a known compromised credential merely to satisfy a routine rollout checklist; coordinate urgent containment with the authorized owner.
Practice
Write a rotation plan with consumer inventory, verification, rollback limits and emergency revocation owner.
Reference candidate: node-secrets-rotation-and-incident-readiness-lookup (route unverified). Original instructional model; independent source review pending.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Secrets rotation and incident readiness — knowledge check
Apply the lesson to a fresh scenario and explain the evidence boundary.
What should rotation logs contain?
What may override routine overlap?
Why verify consumers before routine retirement?