concept

Splat expressions and collection ordering

Project attributes from sequences, understand collection order and adapt a nullable singleton to a zero-or-one sequence.

Formal Syntax & Structure

terraform syntaxterraform
Splat expressions and collection ordering

Working Example

Example Snippetterraform
variable "nodes" {  type = list(object({    name  = string    ports = list(number)  }))  default = [    { name = "worker-b", ports = [8081, 9091] },    { name = "worker-a", ports = [8080, 9090] }  ]}
output "names" {  value = var.nodes[*].name}
output "first_ports" {  value = var.nodes[*].ports[0]}
Terraform Reference
Splat expressions and collection ordering | ByteMind