providers/aws: only retry dependency violation for security groups

[GH-436]
This commit is contained in:
Mitchell Hashimoto 2014-10-17 18:29:48 -07:00
parent b4f8b7f43b
commit 7c89fb06cc
1 changed files with 14 additions and 3 deletions

View File

@ -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
})
}