Declarative vs Imperative IaC
On this page
Declarative vs Imperative (Ops Lens)
- Declarative: define desired end state; tool reconciles.
- Imperative: issue commands that mutate state now.
- Prefer declarative for production to minimize drift and human variance.
When Imperative Is Acceptable
- Break-glass incident actions (documented, time-bounded, followed by reconciliation).
- One-off diagnostics that do not change durable infrastructure state.
Runbook: Break-Glass to Reconcile
- Declare incident and record who/why/when.
- Perform minimal imperative action to stabilize.
- Open a reconciliation PR to match reality back to IaC.
- Run drift detection and close loop.
Example
# Anti-pattern: manual changes become permanent # Better: follow with IaC update and drift check 1) Stabilize (break-glass) 2) Reconcile (IaC PR) 3) Verify (drift is zero)