我觉得我的逻辑很糟糕!
我正在尝试将我的 Azure 网络组关联到我的子网
这是我的安全组配置
resource "azurerm_network_security_group" "azure_nsg" {
depends_on = ["azurerm_virtual_network.vnet"]
location = "${var.region}"
name = "${var.nsg_names[count.index]}" // I think my problem is here
resource_group_name = "${azurerm_resource_group.vnet.name}"
count = "${length(var.nsg_names)}"
}
从这里count.index
我试图导入
resource "azurerm_subnet" "subnet" {
depends_on = ["azurerm_network_security_group.private"]
name = "${var.subnet_names[count.index]}"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
resource_group_name = "${azurerm_resource_group.vnet.name}"
address_prefix = "${var.subnet_prefixes[count.index]}"
network_security_group_id = "${lookup(var.nsg_ids,var.subnet_names[count.index],"")}"
count = "${length(var.subnet_names)}"
}
但我无法 network_security_group_id
使用 [count.index] 或地图进行访问。
* azurerm_subnet.subnet.1: [ERROR] Unable to Parse Network Security Group ID 'databasensg': Cannot parse Azure ID: parse databasensg: invalid URI for request
* module.azure_vnet.azurerm_subnet.subnet[2]: 1 error(s) occurred:
* azurerm_subnet.subnet.2: [ERROR] Unable to Parse Network Security Group ID 'jumpboxnsg': Cannot parse Azure ID: parse jumpboxnsg: invalid URI for request
* module.azure_vnet.azurerm_network_security_group.azure_nsg[1]: 1 error(s) occurred:
对于地球化专家来说,这将非常容易。
请在这里帮忙,