Skip to content

Commit

Permalink
Merge pull request #1057 from hashicorp/digitalocean-droplet-destroy
Browse files Browse the repository at this point in the history
providers/digitalocean: wait for droplet to be unlocked before destroy
  • Loading branch information
pearkes committed Feb 26, 2015
2 parents 8c49955 + 3f21776 commit 7008880
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion builtin/providers/digitalocean/resource_digitalocean_droplet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 7008880

Please sign in to comment.