Merge pull request #1057 from hashicorp/digitalocean-droplet-destroy

providers/digitalocean: wait for droplet to be unlocked before destroy
This commit is contained in:
Jack Pearkes 2015-02-26 09:19:33 -08:00
commit 7008880ac8
1 changed files with 9 additions and 1 deletions

View File

@ -326,10 +326,18 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
func resourceDigitalOceanDropletDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*digitalocean.Client)
_, err := WaitForDropletAttribute(
d, "false", []string{"", "true"}, "locked", meta)
if err != nil {
return fmt.Errorf(
"Error waiting for droplet to be unlocked for destroy (%s): %s", d.Id(), err)
}
log.Printf("[INFO] Deleting droplet: %s", d.Id())
// Destroy the droplet
err := client.DestroyDroplet(d.Id())
err = client.DestroyDroplet(d.Id())
// Handle remotely destroyed droplets
if err != nil && strings.Contains(err.Error(), "404 Not Found") {