为嵌套对象创建 Terraform 变量

Mar*_*vid 5 azure terraform terraform-provider-azure

以下是我的 terraform 模块的变量声明,该模块在我们的云中使用,这些变量的输入是通过自动化解决方案之一获得的。现在,我想重现我想从下面的变量定义创建 tfvars 文件的问题之一。

变量.tf:

variable "docker" {
  type = object({
    image_name    = string
    image_location = string
    docker_ports = object({
      internal = number
      external    = number
    })
    rmodelling = object({
      lang  = object({
        version = number
        enabled    = bool
        policy = object({
          identification = string
        })
      })
      impl = object({
        version   = number
        enabled      = bool
        policy = object({
          identification = string
        })
      })
    })
  })
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试过类似的方法,但是对于下一个嵌套对象,我不太确定如何放下它们。有人可以指导或提供一些指示吗?

terraform.tfvars:

docker = {
  image_name = "Ubuntu 18.04"
  image_location = "https://registry.jd.com/ubuntu/<custom_location>"
  docker_ports = {
    internal = 80
    external = 443
  }
rmodelling = { ??
???
Run Code Online (Sandbox Code Playgroud)

Mar*_*cin 4

您的有效值的一个示例var.docker是:

docker = {
  image_name = "Ubuntu 18.04"
  image_location = "https://registry.jd.com/ubuntu/<custom_location>"
  docker_ports = {
    internal = 80
    external = 443
  }
  rmodelling = { 
      lang = {
            version = 3
            enabled = true
            policy = {
              identification = "test"
            }
      }
      impl = {
        version = 4
        enabled = false
        policy = {
          identification = "test2"
        }      
     }       
  }    

}

Run Code Online (Sandbox Code Playgroud)