Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
For loop 回路创建地图列表的地形模板_For Loop_Templates_Terraform - Fatal编程技术网

For loop 回路创建地图列表的地形模板

For loop 回路创建地图列表的地形模板,for-loop,templates,terraform,For Loop,Templates,Terraform,我想为ip限制创建一个列表,如 [ { ip_address = "185.46.212.12/32" }, { ip_address = "40.67.217.201/32" } ] 在main.tf文件中,我调用 data "template_file" "foo" { template = "${file("${path.root}/ip_restriction.tpl")}" vars { lists = "${azurerm_app

我想为ip限制创建一个列表,如

[
  {
    ip_address  = "185.46.212.12/32"
  },
  {
    ip_address  = "40.67.217.201/32"
  }
]
在main.tf文件中,我调用

data "template_file" "foo" {
  template = "${file("${path.root}/ip_restriction.tpl")}"
  vars {
    lists = "${azurerm_app_service.app1.outbound_ip_addresses}"
  }
}
在ip_restriction.tpl中

[
    list(
      %{ for listItem in "${split(",", lists)}"}
        map("ip_address", "${listItem}/32"),
      %{ endfor }
    )
]
当我在另一个ip_限制中使用它时,它将不起作用。这就是我使用它的方式

ip_restriction =  "${data.template_file.foo.0.rendered}"
有没有一种方法可以创建一个包含动态ip地址的对象的适当列表,我可以将该列表设置为另一个webapp的ip_限制