From f7996e36eabfbbe2b4c2d21514bad6be489ff90b Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Tue, 30 May 2017 19:21:53 +0300 Subject: [PATCH] provider/digitalocean: Refresh DO loadbalancer from state if 404 (#14897) Fixes: #14852 --- .../digitalocean/resource_digitalocean_loadbalancer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin/providers/digitalocean/resource_digitalocean_loadbalancer.go b/builtin/providers/digitalocean/resource_digitalocean_loadbalancer.go index b24556f40..f6ff03a69 100644 --- a/builtin/providers/digitalocean/resource_digitalocean_loadbalancer.go +++ b/builtin/providers/digitalocean/resource_digitalocean_loadbalancer.go @@ -237,8 +237,13 @@ func resourceDigitalOceanLoadbalancerRead(d *schema.ResourceData, meta interface client := meta.(*godo.Client) log.Printf("[INFO] Reading the details of the Loadbalancer %s", d.Id()) - loadbalancer, _, err := client.LoadBalancers.Get(context.Background(), d.Id()) + loadbalancer, resp, err := client.LoadBalancers.Get(context.Background(), d.Id()) if err != nil { + if resp != nil && resp.StatusCode == 404 { + log.Printf("[WARN] DigitalOcean Load Balancer (%s) not found", d.Id()) + d.SetId("") + return nil + } return fmt.Errorf("Error retrieving Loadbalancer: %s", err) }