Pcornel
Automation · Infrastructure as Code

Desired State

Cheat sheet · https://pcornel.dk/topic.php?topic=5424

Back to the Topic

Answer

Desired state is the intended infrastructure condition represented by configuration and resolved inputs, not a guarantee that the live environment already matches it.

Remember

  • Desired state ≠ current state; drift, stale reads, failed applies and out-of-band changes can separate them.
  • State or engine metadata ≠ authoritative live-service health; always confirm with provider read-back and target acceptance checks.
  • A green execution step ≠ complete convergence when later state persistence, external dependencies or workload readiness remain unverified.
  • Provider/API success ≠ business outcome; keep engine evidence and target-domain evidence separate.

First checks

  • Desired state in git per environment — source
  • terraform plan -detailed-exitcode — 0 = in sync
  • Scheduled drift plan — monitoring

Verify in this order

code → compare with real → diff

Where it usually breaks

Desired state ≠ current state; drift, stale reads, failed applies and out-of-band changes can separate them. The proof boundary ends where provider/state evidence stops and target-domain acceptance begins.

Configuration/input → graph/state refresh → plan → provider API request → provider terminal result → resource read-back → effective service state → workload.

Desired State IaC proof-boundary map

BoundaryHealthy evidenceSuspicious evidence
Definition / inputsExact revision, toolchain and effective inputs are reproducibleDifferent runner/version/input context changes evaluation
State / planningCorrect backend/state/lock, fresh reads and reviewed graph/planWrong state/workspace, stale reads, unsafe replacement/destroy or missing lock
ExecutionExpected provider/API operations complete and state persistsPartial apply, auth/API error, ambiguous retry or failed state write
Target proofIndependent read-back plus fresh plan confirm intended convergenceEngine success treated as workload acceptance or drift remains unexplained

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5424

Confirmation

Confirm action

Continue?