DELAPARRA
Index
Color
NL
Category: Terraform

variable

Explained by Updated

What is variable?

variable: A typed input to a configuration or module. Set via -var, *.tfvars files, env vars (TF_VAR_*), or defaults. A variable in Terraform is a typed input to a configuration or module, such as the number of servers or the environment name. You declare it with a type, a description and optionally a default.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about variable

How is variable used in practice?

Values come from .tfvars files, -var options on the command line, environment variables named TF_VAR_name, or the default. This lets the same code create different environments with different settings.

What should you keep in mind with variable?

Add descriptions and types to every variable, so the module documents itself. Use validation blocks to reject impossible values early, such as an unknown region. Mark secrets with sensitive = true, so Terraform hides them in output, and pass them through environment variables or a secret manager rather than committing them in a .tfvars file.

What does an example of variable look like?

variable "instance_count" { type = number default = 2 }

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with V

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.