我无法理解如何引用“当前”定义文件中未定义的子网。
我有两个不同的定义文件,一个用于网络定义(文件 A),另一个用于计算资源(文件 B)。
如何在文件 B 中引用文件 A 中定义的子网?
文件 A包含以下内容
resource "azurerm_resource_group" "NetResourceGroup" {
name = "NetworkResources"
location = "westeurope"
}
resource "azurerm_virtual_network" "vnet" {
name = "mainvnet"
location = "${azurerm_resource_group.NetResourceGroup.location}"
address_space = ["10.0.0.0/16"]
resource_group_name = "${azurerm_resource_group.NetResourceGroup.name}"
}
resource "azurerm_subnet" "dcsubnet" {
name = "dcsubnet"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
resource_group_name = "${azurerm_resource_group.NetResourceGroup.name}"
address_prefix = "10.0.1.0/24"
}
resource "azurerm_subnet" "sqlsubnet" {
name = "sqlsubnet"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
resource_group_name = "${azurerm_resource_group.NetResourceGroup.name}"
address_prefix = "10.0.2.0/24"
}
文件 B包含以下内容:
resource "azurerm_resource_group" "DCResourceGroup" {
name = "DomainControllerVMs"
location = "westeurope"
}
resource "azurerm_storage_account" "DCStorageAccoount" {
name = "domaincontrollersdisks"
location = "${azurerm_resource_group.DCResourceGroup.location}"
resource_group_name = "${azurerm_resource_group.DCResourceGroup.name}"
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_availability_set" "DCAvailabilitySet" {
name = "dcsavailset"
location = "${azurerm_resource_group.DCResourceGroup.location}"
resource_group_name = "${azurerm_resource_group.DCResourceGroup.name}"
platform_fault_domain_count = 2
platform_update_domain_count = 2
managed = true
}
resource "azurerm_network_interface" "dc1nic" {
name = "dcnic${count.index}"
location = "${azurerm_resource_group.DCResourceGroup.location}"
resource_group_name = "${azurerm_resource_group.DCResourceGroup.name}"
ip_configuration {
name = "ipconfig${count.index}"
subnet_id = "${?????????}"
private_ip_address_allocation = "Dynamic"
}
}
提前致谢