provider/digitalocean: Refresh DO loadbalancer from state if 404 (#14897)

Fixes: #14852
This commit is contained in:
Paul Stack 2017-05-30 19:21:53 +03:00 committed by GitHub
parent 9a83d7bff4
commit 38032e9249
1 changed files with 6 additions and 1 deletions

View File

@ -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)
}