World map

 

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 yet
  • random_pet.stallnot built yet

Built (the state file)

Nothing built yet.

Blueprint: 2 resources. Built: 0.

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 yet
  • random_pet.stallnot built yet

Built (the state file)

Nothing built yet.

Blueprint: 2 resources. Built: 0.

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

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 yet
  • random_pet.stallnot built yet

Built (the state file)

Nothing built yet.

Blueprint: 2 resources. Built: 0.

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

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.