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:
Clint 2015-11-05 11:38:32 -06:00
commit c811dc98fd
1 changed files with 3 additions and 2 deletions

View File

@ -186,10 +186,11 @@ func resourceDigitalOceanDropletRead(d *schema.ResourceData, meta interface{}) e
}
// Retrieve the droplet properties for updating the state
droplet, _, err := client.Droplets.Get(id)
droplet, resp, err := client.Droplets.Get(id)
if err != nil {
// 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("")
return nil
}