World map

 

BM: Baca dalam Bahasa Melayu

World T1: Blueprints

apply and destroy

You will learn: to build with apply, and to tear down safely with destroy.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

You built a test stall to try an idea. The test is over. In the cloud, a stall costs money every hour. What now?

Pick one answer.

Try it

Build the stall first. Type tofu apply. Read the plan it shows. Then type yes.

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

At the question you type y, not yes. What happens?

Pick one answer.

Try it

Now tear it down. Type tofu destroy. Read the red note, then answer yes.

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.

destroy: Tear down everything the blueprint built. OpenTofu lists what goes and waits for yes. deletes real things. Careful: always read its list first.

Check

Put the safe building loop in order.

First step at the top. Put these in order. Use the arrows, or drag.

  • Change the blueprint (.tf files)
  • tofu destroy: when the test is over
  • tofu plan: read what will happen
  • tofu apply: type yes only if the plan looks right

Check

-auto-approve skips the question. Good idea or not?

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

1 / 4

apply -auto-approve on your practice laptop

apply -auto-approve on your practice laptop

You did it!

You can now build with apply and tear down with destroy, safely.

Go deeper (optional)

tofu plan -destroy shows what destroy would delete, and deletes nothing. tofu destroy is the same as tofu apply -destroy. Careful: -auto-approve skips the question. Use it only in practice, or in a pipeline that showed a plan first.