World map

 

BM: Baca dalam Bahasa Melayu

World T3: State & Teams

state list, show and rm

You will learn: how to look inside the register, and why rm only makes OpenTofu forget.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

The register holds five things now. The boss asks: “Which table number did we get?” You don’t want to dig through raw JSON. What do you use?

Pick one answer.

Try it

First list everything: tofu state list. Then look at one: tofu state show random_integer.table.

Blueprint (your .tf files)init done

  • local_file.menu
  • local_file.sign
  • random_integer.table
  • random_pet.stall
  • terraform_data.bell

Built (the state file)state #1

  • local_file.menu
  • local_file.sign
  • random_integer.table
  • random_pet.stall
  • terraform_data.bell
Blueprint: 5 resources. Built: 5.

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

Check

This is tofu state show local_file.sign. Find what the sign says.

Tap the line with the sign's words.

0 of 1 found

Predict

Now tofu state rm local_file.sign. What happens to sign.txt?

Pick one answer.

Try it

⚠️ Careful: state rm makes OpenTofu forget a real thing. Try it here: tofu state rm local_file.sign. Then tofu plan.

Blueprint (your .tf files)init done

  • local_file.menu
  • local_file.sign
  • random_integer.table
  • random_pet.stall
  • terraform_data.bell

Built (the state file)state #1

  • local_file.menu
  • local_file.sign
  • random_integer.table
  • random_pet.stall
  • terraform_data.bell
Blueprint: 5 resources. Built: 5.

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

Check

Sort the commands: do they only read, or do they change the register?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now read the register and know what state rm really does.

      Go deeper (optional)

      Each state command that changes the register saves a timestamped backup first, like terraform.tfstate.1793491219.backup. The reviewable way to forget a thing is a removed block in the code. OpenTofu 1.13 also has lifecycle { destroy = false }: forget it instead of destroying it.

      Real mission

      1. tofu init && tofu apply
      2. tofu state list
      3. tofu state show local_file.<name>
      4. tofu state rm local_file.<name> && tofu plan

      0 of 4 steps done · Your ticks are saved.