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.signrandom_pet.stall
Built (the state file)state #1
local_file.signrandom_pet.stall
- stall_name
- lucky-civet
Change a file, then run tofu plan to see what it means.
Hint
Typetofu state list.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.signrandom_pet.stall
Built (the state file)state #1
local_file.signrandom_pet.stall
- stall_name
- lucky-civet
Change a file, then run tofu plan to see what it means.
Hint
rm sign.txt, then tofu plan.Check
Good habit or not?
Swipe right for good, left for needs work. Or use the buttons.
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.
Bahasa Melayu
Semalam OpenTofu bina sign.txt. Hari ini anda jalankan plan lagi. Macam mana OpenTofu tahu sign.txt itu miliknya?
Daftar itu ialah fail state (daftar bangunan), terraform.tfstate. Taip tofu state list untuk baca isinya.
tofu state list.tofu state show random_pet.stall paparkan satu catatan. Tekan baris dengan nama yang OpenTofu pilih.
Seseorang padam sign.txt dengan tangan. Daftar masih senaraikannya. Apa tofu plan akan kata?
Cuba. Taip rm sign.txt, kemudian tofu plan.
rm sign.txt, kemudian tofu plan.Tabiat baik atau tidak?
Kini anda boleh baca state dan terangkan kenapa ia penting.
You finished this before. Practice is always welcome!
Official docs: OpenTofu: state Β· OpenTofu: purpose of state Β· tofu state
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?