azure - 无效或未知 key : network_security_group_id

标签 azure terraform terraform-provider-azure

这是我的代码块,用于使用 Terrfaorm 在 Azure 中创建网络接口(interface)并附加安全组。我在另一个模块中使用了相同的内容,但运行时出现错误:

resource "azurerm_network_interface" "myterraformnic" {
  name                      = "${var.vm_name}-nic"
  location                  = "${azurerm_resource_group.sdsterraformgroup.location}"
  resource_group_name       = "${azurerm_resource_group.sdsterraformgroup.name}"
  network_security_group_id = "${azurerm_network_security_group.myterraformnsg.id}"
}

这是我运行计划或应用时遇到的错误:

**"Error: azurerm_network_interface.myterraformnic: : invalid or unknown key: network_security_group_id"**

最佳答案

terraform 中的

azurerm_network_interface 资源没有network_security_group_id 参数。

如果您尝试将网络安全组与网络接口(interface)关联,请对 terraform 资源 block 进行如下更改

resource "azurerm_network_interface" "myterraformnic" {
  name                      = "${var.vm_name}-nic"
  location                  = "${azurerm_resource_group.sdsterraformgroup.location}"
  resource_group_name       = "${azurerm_resource_group.sdsterraformgroup.name}"
}

resource "azurerm_network_interface_security_group_association" "example" {
  network_interface_id      = azurerm_network_interface.myterraformnic.id
  network_security_group_id = "${azurerm_network_security_group.myterraformnsg.id}"
}

通过如上所述更改模板,“azurerm_network_interface”资源 block 将创建网络接口(interface),并且网络安全组将与“azurerm_network_interface_security_group_association”资源 block 中的网络接口(interface)相关联 p>

关于azure - 无效或未知 key : network_security_group_id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60935359/

相关文章:

azure - 在 Azure Devops CI/CD 管道中为 MS Edge 浏览器运行 Protractor E2E 测试

kubernetes - 使用 terraform 将公共(public) GKE 更改为私有(private) GKE 集群

terraform - 有没有办法让 terraform 忽略 ResourceNotFoundException 并破坏其他资源

azure - 如何在 Azure 中使用 Terraform 创建多个安全规则?

azure - 如何有条件地跳过使用 terraform 创建/实现的部分 terraform 资源

azure - 连接-AzureRmAccount : Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll'

c# - 如何将 EntityResolver 与 Azure 存储结合使用?

Azure 策略分配 - 排除资源类型

terraform - 破坏特定的地形基础设施

azure - 通过 Terraform 部署应用程序网关时出错