expression
What is expression?
expression: Anything that produces a value — a literal, a reference, a function call, or arithmetic. An expression in Terraform is anything that produces a value. It can be a literal like "t3.micro", a reference like var.region, a function call like length(var.zones), or a combination such as var.count * 2. Expressions let one configuration adapt to different situations. The same code can create one small server in staging and three larger ones in production, based on variables.
Frequently asked questions about expression
What should you keep in mind with expression?
Keep them readable. A conditional like var.env == "prod" ? 3 : 1 is fine. A line with nested functions and conditionals that needs careful study is a sign the logic belongs in a local value with a clear name. terraform console is useful for testing expressions interactively against your real state before you put them in the configuration.
What does an example of expression look like?
max(var.min_size, length(var.azs)) At a glance
| Category | Terraform |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |