BM: Baca dalam Bahasa Melayu
World T1: Blueprints
fmt and validate
You will learn: to catch mistakes with validate and tidy the layout with fmt.
Checked with OpenTofu 1.13 on 1 Nov 2026
The problem
A tired architect drew this blueprint. Type tofu validate to check it.
Blueprint (your .tf files)init done
local_file.signnot built yetrandom_pet.stallnot built yet
Built (the state file)
Nothing built yet.
Change a file, then run tofu plan to see what it means.
Error: Reference to undeclared resource. Plain words: stal is not a name in this blueprint.
Watch
Errors say where to look. Tap the line that names the file and the line number.
Tap the lines that match.
0 of 1 found
Try it
Fix the blueprint until tofu apply works. Run tofu validate after each fix.
Blueprint (your .tf files)init done
local_file.signnot built yetrandom_pet.stallnot built yet
Built (the state file)
Nothing built yet.
Change a file, then run tofu plan to see what it means.
Hint
Fix one error, thentofu validate again. A new one may appear.Predict
tofu fmt lines up the = signs and fixes the spaces. Does it change what gets built?
Pick one answer.
Try it
This blueprint works but looks messy. Type tofu fmt. Then open main.tf again.
Blueprint (your .tf files)needs tofu init
local_file.menunot built yetrandom_pet.stallnot built yet
Built (the state file)
Nothing built yet.
Change a file, then run tofu plan to see what it means.
Hint
Typetofu fmt.Check
Whose job is it?
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now check a blueprint with validate and tidy it with fmt.
Go deeper (optional)
tofu fmt -check changes nothing. It lists messy files and fails, so CI can stop untidy code. -diff shows the changes; -recursive tidies sub-folders too. validate needs tofu init first, but never reads the state or the real things. Many editors run fmt each time you save.
Bahasa Melayu
Seorang arkitek yang penat lukis pelan ini. Taip tofu validate untuk menyemaknya.
Error: Reference to undeclared resource. Maksudnya: stal bukan nama dalam pelan ini.
Ralat beritahu di mana nak tengok. Tekan baris yang sebut nama fail dan nombor baris.
Baiki pelan sampai tofu apply berjaya. Jalankan tofu validate selepas setiap pembetulan.
tofu validate lagi. Ralat baru mungkin muncul.tofu fmt susun tanda = sebaris dan betulkan ruang. Adakah ia ubah apa yang dibina?
Pelan ini berfungsi tapi nampak bersepah. Taip tofu fmt. Kemudian buka main.tf semula.
tofu fmt.Kerja siapa ini?
Kini anda boleh semak pelan dengan validate dan kemaskan dengan fmt.
You finished this before. Practice is always welcome!
Official docs: tofu validate ยท tofu fmt ยท OpenTofu: style conventions
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?