World map

 

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 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.

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 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.

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.

1 / 3

The stall name, for the menu printer

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).