Skip to content

Commit

Permalink
providers/aws: only retry dependency violation for security groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Oct 18, 2014
1 parent b4f8b7f commit 7c89fb0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions builtin/providers/aws/resource_aws_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,27 @@ func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) er

log.Printf("[DEBUG] Security Group destroy: %v", d.Id())

return resource.Retry(5 * time.Minute, func() error {
return resource.Retry(5*time.Minute, func() error {
_, err := ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: d.Id()})
if err != nil {
ec2err, ok := err.(*ec2.Error)
if ok && ec2err.Code == "InvalidGroup.NotFound" {
if !ok {
return err
}

switch ec2err.Code {
case "InvalidGroup.NotFound":
return nil
case "DependencyViolation":
// If it is a dependency violation, we want to retry
return err
default:
// Any other error, we want to quit the retry loop immediately
return resource.RetryError{err}
}
}

return err
return nil
})
}

Expand Down

0 comments on commit 7c89fb0

Please sign in to comment.