I’m migrating my config from azurerm 1.44 to 2.3.0 and need to use the new config item azurerm_network_interface_security_group_association
When I do my plan all seems good:
Terraform will perform the following actions:
# 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"
}
But when I come to apply I get this which doesn’t make sense as the resource “vm-0” is being managed by 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" {