World map

 

BM: Baca dalam Bahasa Melayu

World T1: Blueprints

State: the building's register

You will learn: how OpenTofu remembers what it built, and why the state file matters.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

Yesterday OpenTofu built sign.txt. Today you run a plan again. How does OpenTofu know sign.txt is its own?

Pick one answer.

Try it

The register is the state: The building's register: terraform.tfstate. It records what OpenTofu built, so the next plan can compare. file, terraform.tfstate. Type tofu state list to read its entries.

Blueprint (your .tf files)init done

  • local_file.sign
  • random_pet.stall

Built (the state file)state #1

  • local_file.sign
  • random_pet.stall
stall_name
lucky-civet
Blueprint: 2 resources. Built: 2.

Change a file, then run tofu plan to see what it means.

Watch

tofu state show random_pet.stall prints one entry. Tap the line with the name OpenTofu picked.

Tap the lines that match.

0 of 1 found

Predict

Someone deletes sign.txt by hand. The register still lists it. What will tofu plan say?

Pick one answer.

Try it

Try it. Type rm sign.txt, then tofu plan.

Blueprint (your .tf files)init done

  • local_file.sign
  • random_pet.stall

Built (the state file)state #1

  • local_file.sign
  • random_pet.stall
stall_name
lucky-civet
Blueprint: 2 resources. Built: 2.

Change a file, then run tofu plan to see what it means.

Check

Good habit or not?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4

Keep terraform.tfstate safe, with a backup

Keep terraform.tfstate safe, with a backup

You did it!

You can now read the state and explain why it matters.

Go deeper (optional)

The state is JSON. Its serial number goes up after each change, and terraform.tfstate.backup keeps the one before. tofu show prints the whole state in a readable way. On a team, the state lives in a shared backend with a lock. Then two people can’t build at once. World T3 covers that.