【问题标题】:Selecting specific subnet id from virtual network with multiple subnets从具有多个子网的虚拟网络中选择特定的子网 ID
【发布时间】:2019-07-19 18:51:37
【问题描述】:

我想在另一个资源块中引用 subnet 2 的 ID,但子网没有索引值。即“${azurerm_virtual_network.test.subnet.2.id}”将不起作用。

resource "azurerm_virtual_network" "test" {
  name                = "virtualNetwork1"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
  address_space       = ["10.0.0.0/16"]
  dns_servers         = ["10.0.0.4", "10.0.0.5"]

  subnet {
    name           = "subnet1"
    address_prefix = "10.0.1.0/24"
  }

  subnet {
    name           = "subnet2"
    address_prefix = "10.0.2.0/24"
  }

  subnet {
    name           = "subnet3"
    address_prefix = "10.0.3.0/24"
    security_group = "${azurerm_network_security_group.test.id}"
  }
}

【问题讨论】:

    标签: terraform terraform-provider-azure


    【解决方案1】:

    Expose ID of an embedded subnet defined in azurerm_virtual_network #1913的帮助下解决了

    ...
    subnet_id = "${azurerm_virtual_network.test.subnet.*.id[1]}"
    ...
    

    【讨论】:

      猜你喜欢
      • 2018-09-22
      • 2021-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      相关资源
      最近更新 更多