variable blocks define a module's input interface, letting consumers customize behavior at runtime without altering module source code; hardcoded values make a module inflexible and hard to reuse. Reference variables with var.<NAME> syntax. A variable without a default makes Terraform prompt for a value before it generates a plan, and an optional validation block enforces that input values meet module requirements. output blocks expose infrastructure data: child modules expose resource attributes to parent modules, which reference them as module.<CHILD_MODULE_NAME>.<OUTPUT_NAME>; root module outputs print in the CLI after apply; and other configurations can read root module outputs through the terraform_remote_state data source. Mark sensitive variables and outputs with sensitive = true to redact CLI display, but note that Terraform still stores sensitive output values in state, and terraform output with the -json or -raw flags prints them in plain text. Adding the ephemeral argument to an output omits its value from state and plan files, at the cost of restrictions on assignable values. Scope: Terraform. Reviewed October 4, 2026.
Input variables and outputs
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- developer.hashicorp.com
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.