conditional expression

An expression that checks a condition and evaluates to one of two values, one for true and one for false.

In more detail

Languages write it differently: Python uses value_if_true if condition else value_if_false, while Terraform and many other languages use condition ? true_value : false_value. It suits short choices, such as a large size in production and a small one elsewhere. Keep both sides short so the choice stays easy to read.

Example

tier = var.production ? "large" : "small"

Related terms

Taught in

References

Certification courses