Terragrunt 或 Terraform 在变量中定义了一个未知数量的对象 key/values

Terragrunt or Terraform define an object in variable with not known number of key/values

我有一个对象(桶)列表,我想用我的模块创建这些对象

  buckets = [
    {
      name                        = "my_bucket",
      location                    = "EU"
      storage_class               = "STANDARD"
      force_destroy               = false
      versioning                  = true
      uniform_bucket_level_access = false
      public_bucket               = true
      labels = {
        "app" = "my_app"
      }

有些字段是必填字段(如名称和位置),有些字段不是,如果此处未提供,我在资源中为它们提供了默认值; - 完整的模块和一切都是可操作的,但它没有在变量中定义 'type' 工作 - 所以它只需要一切,但我的问题是如何在 variable 块中定义该对象?

variable "buckets" {
  #type = list(object()) #? 
  type = set(object({
      name                        = string
      location                    = string
      storage_class               = string
      force_destroy               = boolean
      versioning                  = boolean
      uniform_bucket_level_access = boolean
      public_bucket               = boolean
      labels = object({
        string = string # ?
      })
  }))
}

具有可选字段的对象看起来如何

https://github.com/hashicorp/terraform/issues/19898 https://discuss.hashicorp.com/t/map-object-with-optional-attributes/6714

显然这似乎还不可能..