providers/digitalocean: wait for droplet to be unlocked before destroy

This commit is contained in:
Jack Pearkes 2015-02-25 16:54:39 -08:00
parent f2e92cfeab
commit 3f217763c7
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 { func resourceDigitalOceanDropletDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*digitalocean.Client) 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()) log.Printf("[INFO] Deleting droplet: %s", d.Id())
// Destroy the droplet // Destroy the droplet
err := client.DestroyDroplet(d.Id()) err = client.DestroyDroplet(d.Id())
// Handle remotely destroyed droplets // Handle remotely destroyed droplets
if err != nil && strings.Contains(err.Error(), "404 Not Found") { if err != nil && strings.Contains(err.Error(), "404 Not Found") {