小编The*_*707的帖子

如何通过 Terraform 0.12 中的列表(对象)for_each

我需要部署 GCP 计算实例列表。我如何通过像这样的对象列表中的“vms”循环 for_each:

    "gcp_zone": "us-central1-a",
    "image_name": "centos-cloud/centos-7",
    "vms": [
      {
        "hostname": "test1-srfe",
        "cpu": 1,
        "ram": 4,
        "hdd": 15,
        "log_drive": 300,
        "template": "Template-New",
        "service_types": [
          "sql",
          "db01",
          "db02"
        ]
      },
      {
        "hostname": "test1-second",
        "cpu": 1,
        "ram": 4,
        "hdd": 15,
        "template": "APPs-Template",
        "service_types": [
          "configs"
        ]
      }
    ]    
}
Run Code Online (Sandbox Code Playgroud)

foreach loops list object terraform

43
推荐指数
5
解决办法
7万
查看次数

标签 统计

foreach ×1

list ×1

loops ×1

object ×1

terraform ×1