diff --git a/builtin/providers/vcd/resource_vcd_network.go b/builtin/providers/vcd/resource_vcd_network.go index c984d708e..b247be5da 100644 --- a/builtin/providers/vcd/resource_vcd_network.go +++ b/builtin/providers/vcd/resource_vcd_network.go @@ -207,7 +207,9 @@ func resourceVcdNetworkRead(d *schema.ResourceData, meta interface{}) error { network, err := vcd_client.OrgVdc.FindVDCNetwork(d.Id()) if err != nil { - return fmt.Errorf("Error finding network: %#v", err) + log.Printf("[DEBUG] Network no longer exists. Removing from tfstate") + d.SetId("") + return nil } d.Set("name", network.OrgVDCNetwork.Name) diff --git a/builtin/providers/vcd/resource_vcd_vapp.go b/builtin/providers/vcd/resource_vcd_vapp.go index ee50d63ea..c50037868 100644 --- a/builtin/providers/vcd/resource_vcd_vapp.go +++ b/builtin/providers/vcd/resource_vcd_vapp.go @@ -355,7 +355,9 @@ func resourceVcdVAppRead(d *schema.ResourceData, meta interface{}) error { vapp, err := vcd_client.OrgVdc.FindVAppByName(d.Id()) if err != nil { - return fmt.Errorf("Error finding vapp: %#v", err) + log.Printf("[DEBUG] Unable to find vapp. Removing from tfstate") + d.SetId("") + return nil } d.Set("ip", vapp.VApp.Children.VM[0].NetworkConnectionSection.NetworkConnection.IPAddress)