input variable

A named, typed value a configuration or module takes from outside, declared in a variable block and read as var.<name>.

In more detail

A good declaration has a description, a type, a validation rule where useful and, if safe, a default. Values can come from defaults, TF_VAR_ environment variables, .tfvars files and the -var and -var-file options, with a fixed order of precedence. If no value and no default exist, Terraform prompts, or fails when input is turned off.

Examples

variable "environment" {
  description = "Name of the environment this configuration builds."
  type        = string
}
filename = "${var.environment}.json"

Related terms

Taught in

References

Certification courses