Я ссылаюсь на существующие подсети, как показано ниже, но я хочу, чтобы NSG был создан и подключен к подсети.Это дает мне ошибку.
Код для повторного добавления и добавления NSG ниже:
data "azurerm_subnet" "tf-sn-erx-app" {
name = "${var.subnet_app_name}"
virtual_network_name = "${data.azurerm_virtual_network.tf-vn-erx.name}"
resource_group_name = "${data.azurerm_resource_group.tf-rg-erx-external.name}"
security_group = "${azurerm_network_security_group.tf-nsg-erx-application.id}"
}
data "azurerm_subnet" "tf-sn-erx-sql" {
name = "${var.subnet_sql_name}"
virtual_network_name = "${data.azurerm_virtual_network.tf-vn-erx.name}"
resource_group_name = "${data.azurerm_resource_group.tf-rg-erx-external.name}"
security_group = "${azurerm_network_security_group.tf-nsg-erx-sql.id}"
}
resource "azurerm_network_security_group" "tf-nsg-erx-application" {
name = "${var.application_nsg}"
location = "${data.azurerm_resource_group.tf-rg-erx-external.location}"
resource_group_name = "${data.azurerm_resource_group.tf-rg-erx-external.name}"
}
resource "azurerm_network_security_rule" "tf-nsr-erx-application-5985" {
name = "Open Port 5985"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "5985"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "${data.azurerm_resource_group.tf-rg-erx-external.name}"
network_security_group_name = "${azurerm_network_security_group.tf-nsg-erx-application.name}"
}
resource "azurerm_network_security_rule" "tf-nsr-erx-application-5986" {
name = "Open Port 5986"
priority = 101
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "5986"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "${data.azurerm_resource_group.tf-rg-erx-external.name}"
network_security_group_name = "${azurerm_network_security_group.tf-nsg-erx-application.name}"
}
Однако, когда я запускаю, terraform, ниже сообщается об ошибке.
Error: data.azurerm_subnet.tf-sn-erx-app: : invalid or unknown key: security_group
Error: data.azurerm_subnet.tf-sn-erx-sql: : invalid or unknown key: security_group
В чем проблема?