Merge pull request #3768 from stack72/f-digitalocean-droplet-404
provider/digitalocean: Fixing the DigitalOcean Droplet 404 potential on refresh of state
This commit is contained in:
commit
c811dc98fd
|
@ -186,10 +186,11 @@ func resourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) e
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the droplet properties for updating the state
|
// Retrieve the droplet properties for updating the state
|
||||||
droplet, _, err := client.Droplets.Get(id)
|
droplet, resp, err := client.Droplets.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// check if the droplet no longer exists.
|
// check if the droplet no longer exists.
|
||||||
if err.Error() == "Error retrieving droplet: API Error: 404 Not Found" {
|
if resp.StatusCode == 404 {
|
||||||
|
log.Printf("[WARN] DigitalOcean Droplet (%s) not found", d.Id())
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue