Infrastructure as Code

Infrastructure as code describes environments in version-controlled files instead of manual console clicks.

Intermediate 5 min DevOps
Desired state · plan · apply · reconcile
  • Desired state
  • Reconcile
  • Drift
DESIRED STATE · main.tfDeclared, not clickednetwork "core" { cidr = "10.0.0.0/16"}service "web" { network = core replicas = 3}database "orders" { size = "small"}PULL REQUEST · REVIEWEDScale web tier- replicas = 2+ replicas = 3History, diff, rollback — same asany application change.STEP 1 · PLANNothing changes yet~ service.web replicas: 2 → 3+ 1 instance0 to add · 1 to change · 0 to destroySTEP 2 · APPLYReconcile to desiredExecutes only the approved changeset, in dependency order.network → service → databasematching resources untouchedPROVIDER APIcreate · update · deleteThe same APIs the console calls.REAL RESOURCES · WHAT EXISTS NOWNETWORK · coreCreated firstEverything below references it, so the ordering is derived, not scripted.unchangedSERVICE · web3 instances+ 1 added by applyDATABASE · orderssize: mediumcode says: smallChanged outside the code.MANUAL CHANGE · WEB CONSOLEResized by handA quick fix during an incident —never written back to the code.DRIFT DETECTED1 differencemedium → smallFeeds the next plan.STATE · METADATAThe bookkeepingNot the code. Not the cloud.RUN AGAIN · IDEMPOTENTNO CHANGESSame file, same reality —so the tooling does nothing.0 add · 0 change · 0 destroy
Infrastructure as code is a loop: declare the end state, read the computed change, let the tooling reconcile real resources — and see drift when reality quietly moves away from the file.

Hover the definition, the review diff, plan, apply, the provider API, any resource, state, the manual change or the drift detector to isolate related elements; click any component for a short explanation.

Next conceptMonitoring and AlertingMonitoring turns system signals into a small number of alerts that are worth waking someone for.