Spread operator at terraform files

2.3k views Asked by At

I want simplify such construction

variable "google" {
  type = object({
    project      = string
    region       = string
    zone         = string
  })
}

provider "google" {
  project = var.google.project
  region  = var.google.region
  zone    = var.google.zone
}

Does HCL have something similar to spread operator?

1

There are 1 answers

0
Martin Atkins On

What you've written here is the shortest possible way to write what you've shown in the Terraform language. There is no mechanism to populate the arguments of a block dynamically from the attributes of an object.