无法从用于网络接口安全组的AzureRM v1迁移到v2,无法应用

时间:2020-04-02 09:21:27

标签: terraform terraform-provider-azure

我要将我的配置从azurerm 1.44迁移到2.3.0,需要使用新的配置项azurerm_network_network_interface_security_group_association

我做完计划后,一切似乎都很好:

Terraform将执行以下操作:

  # module.web-msg.azurerm_network_interface_security_group_association.main[0] will be created
  + resource "azurerm_network_interface_security_group_association" "main" {
      + id                        = (known after apply)
      + network_interface_id      = "/subscriptions/xxxx/resourceGroups/vm-0/providers/Microsoft.Network/networkInterfaces/vm-0-nic"
      + network_security_group_id = "/subscriptions/xxxx/resourceGroups/vm-0/providers/Microsoft.Network/networkSecurityGroups/MsgHubNetworkSecurityGroup"
    }

  # module.web-msg.azurerm_network_interface_security_group_association.main[1] will be created
  + resource "azurerm_network_interface_security_group_association" "main" {
      + id                        = (known after apply)
      + network_interface_id      = "/subscriptions/xxxx/resourceGroups/vm-1/providers/Microsoft.Network/networkInterfaces/vm-1-nic"
      + network_security_group_id = "/subscriptions/xxxx/resourceGroups/vm-1/providers/Microsoft.Network/networkSecurityGroups/MsgHubNetworkSecurityGroup"
    }

但是当我开始申请时,由于资源“ vm-0”是由terraform管理的,所以这没有意义。

terraform apply .\the.plan
module.web-msg.azurerm_network_interface_security_group_association.main[0]: Creating...
module.web-msg.azurerm_network_interface_security_group_association.main[1]: Creating...

Error: A resource with the ID "vm-0" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface_security_group_association" for more information.

  on ..\..\..\infra\terraform\global\msghub\main.tf line 52, in resource "azurerm_network_interface_security_group_association" "main":
  52: resource "azurerm_network_interface_security_group_association" "main" {



Error: A resource with the ID "vm-1" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface_security_group_association" for more information.

  on ..\..\..\infra\terraform\global\msghub\main.tf line 52, in resource "azurerm_network_interface_security_group_association" "main":
  52: resource "azurerm_network_interface_security_group_association" "main" {

0 个答案:

没有答案