From 72e4dd005c0757940fa943000ceea901a79c4ba2 Mon Sep 17 00:00:00 2001 From: Yuping Wei <56525716+yupwei68@users.noreply.github.com> Date: Wed, 24 Jun 2020 11:13:06 +0800 Subject: [PATCH] `azurerm_network_interface_security_group_association` remove itself when NIC not found (#7459) Fix: #7041 --- ...terface_application_security_group_association_resource.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azurerm/internal/services/network/network_interface_application_security_group_association_resource.go b/azurerm/internal/services/network/network_interface_application_security_group_association_resource.go index 77104acd8b768..97d6fabe45c9d 100644 --- a/azurerm/internal/services/network/network_interface_application_security_group_association_resource.go +++ b/azurerm/internal/services/network/network_interface_application_security_group_association_resource.go @@ -82,7 +82,9 @@ func resourceArmNetworkInterfaceApplicationSecurityGroupAssociationCreate(d *sch read, err := client.Get(ctx, resourceGroup, networkInterfaceName, "") if err != nil { if utils.ResponseWasNotFound(read.Response) { - return fmt.Errorf("Network Interface %q (Resource Group %q) was not found!", networkInterfaceName, resourceGroup) + log.Printf("[INFO] Network Interface %q does not exist - removing from state", d.Id()) + d.SetId("") + return nil } return fmt.Errorf("Error retrieving Network Interface %q (Resource Group %q): %+v", networkInterfaceName, resourceGroup, err)