From 38032e92497659ff5d949188f2c3a8066f1bea1b 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 --- resource_digitalocean_loadbalancer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resource_digitalocean_loadbalancer.go b/resource_digitalocean_loadbalancer.go index b24556f4..f6ff03a6 100644 --- a/resource_digitalocean_loadbalancer.go +++ b/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) }