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 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
tofu apply, read, then yes.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.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.
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.
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.
Bahasa Melayu
Anda bina gerai ujian untuk cuba satu idea. Ujian sudah selesai. Dalam cloud, gerai kena bayar setiap jam. Sekarang apa?
Bina gerai itu dulu. Taip tofu apply. Baca plan yang ia tunjuk. Kemudian taip yes.
tofu apply, baca, kemudian yes.Pada soalan itu anda taip y, bukan yes. Apa jadi?
Sekarang robohkan. Taip tofu destroy. Baca nota merah, kemudian jawab yes.
destroy padam benda sebenar. Hati-hati: sentiasa baca senarainya dulu.
Susun kitaran bina yang selamat.
-auto-approve langkau soalan itu. Idea bagus atau tidak?
Kini anda boleh bina dengan apply dan robohkan dengan destroy, dengan selamat.
You finished this before. Practice is always welcome!
Official docs: tofu apply ยท tofu destroy
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?