BM: Baca dalam Bahasa Melayu
World T2: Inputs & Outputs
Outputs
You will learn: to share built values with outputs, and read them with tofu output.
Checked with OpenTofu 1.13 on 1 Nov 2026
The problem
OpenTofu picked a random stall name. The menu printer needs that name. Where does your teammate find it?
Pick one answer.
Try it
Build it, then read the outputs: tofu apply, yes, then tofu output.
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.
An output: A value the blueprint shares after apply, like a stall's name. tofu output prints it. is a value the blueprint shares after apply.
Watch
A script needs just the name, with no quotes. Build that command.
Tap the pieces in the right order.
Predict
You add only a new output block, nothing else. What does the plan say?
Pick one answer.
Try it
Open outputs.tf. Add the output below. Then tofu apply, and 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.
output "sign_filename" {
value = local_file.sign.filename
}Check
A good output or not?
Swipe right for good, left for needs work. Or use the buttons.
The stall name, for the menu printer
You did it!
You can now share built values with outputs.
Go deeper (optional)
tofu output -json prints every output as JSON for other programs. sensitive = true on an output hides it on screen; tofu output -raw still shows it. Outputs also pass values out of modules (World T4).
Bahasa Melayu
OpenTofu pilih nama gerai secara rawak. Pencetak menu perlukan nama itu. Di mana rakan anda boleh jumpa?
Bina dulu, kemudian baca output: tofu apply, yes, kemudian tofu output.
Output ialah nilai yang pelan kongsi selepas apply.
Satu skrip cuma perlukan nama itu, tanpa tanda petik. Bina arahannya.
Anda cuma tambah satu blok output baru, tiada yang lain. Apa plan kata?
Buka outputs.tf. Tambah output di bawah. Kemudian tofu apply, dan yes.
output "sign_filename" {
value = local_file.sign.filename
}
Output yang baik atau tidak?
Kini anda boleh kongsi nilai yang dibina dengan output.
You finished this before. Practice is always welcome!
Official docs: OpenTofu: output values ยท tofu output
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?