Terraform concatenate sublists
This can be achieved easily with combining a splat
expression with flatten
function:
locals {
cars = flatten([
var.users[*].cars
])
}
Other solution would be to use a for
expression:
locals {
cars = flatten([
for user in var.users: user.cars
])
}
The result for cars
in both cases will be:
cars = [
"z1",
"z2",
"x1",
"x2",
]