DELAPARRA
Index
Color
NL
Category: Terraform

expression

Explained by Updated

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.

Definition source Coders Lingo, CC BY 4.0

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

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with E

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.