【发布时间】:2020-08-14 09:03:14
【问题描述】:
我正在尝试在同一代码中访问虚拟网络中的资源组名称,已使用 CSV 文件定义了一些参数,但是当我在代码中调用该参数时显示错误,
请查看以下代码
provider "azurerm" {
features {}
}
locals {
group_names = csvdecode(file("./test.csv"))
}
//Create a resource group and nsg
resource "azurerm_resource_group" "Customer" {
count = length(local.group_names)
name = local.group_names[count.index].resource_group_name
location = local.group_names[count.index].region
}
//Create a Vnet
resource "azurerm_virtual_network" "Customer" {
count = length(local.group_names)
name = local.group_names[count.index].virtual_network_name
location = azurerm_resource_group.Customer.location
resource_group_name = azurerm_resource_group.Customer.name
address_space = [local.group_names[count.index].address_space]
}
//create Subnet
resource "azurerm_subnet" "Customer" {
count = length(local.group_names)
name = local.group_names[count.index].subnet_name
resource_group_name = azurerm_resource_group.Customer.name
virtual_network_name = azurerm_virtual_network.Customer.name
address_prefix = local.group_names[count.index].address_prefix_subnet
}
【问题讨论】:
标签: terraform interrupt-handling terraform-provider-azure terraform-template-file terraform0.12+