Lessons/The Mental Model

The Mental Model

Before you write a single line of Terraform, you need the picture in your head. Everything Terraform does is one loop:

  1. Desired state — what you declare in code (.tf files).
  2. Plan — Terraform compares your desired state to what it last recorded (its state) and the real world, then shows you the diff.
  3. Apply — Terraform makes the real world match your code, and updates state.

That's it. Terraform is a reconciliation loop: desired → diff → converge.

Two ideas make the rest of the course click:

  • State is Terraform's memory. It's how Terraform knows which real resources it already created, so a second apply with no code changes does nothing. That property is called idempotency.
  • The plan is a preview, not the change. You always read the plan before you apply — it's the diff between intent and reality.

Below, you don't write any code yet. You'll see three panes — Code, State, and Real Infrastructure — and for each scenario you predict what plan and apply will do. Get at least 3 of 4 right to finish.

Scenario 1 / 40 answered · need 3 right

Nothing exists yet

Code

resource "demo_server" "web" {
  name = "web"
}

State

Terraform's memory

empty — nothing here yet

Real Infrastructure

the actual world

empty — nothing here yet

You run `terraform plan`. What does it show?