for expression

An expression that builds a new list or map by transforming each element of another collection, as in [for n in var.names : lower(n)].

In more detail

Square brackets produce a list and braces produce a map, and an if clause can filter elements. It transforms values only; to create one resource per element you use count or for_each instead.

Examples

[for name in var.names : lower(trimspace(name))]
{ for k, v in null_resource.subnet : k => v.id }

Related terms

Taught in

References

Certification courses