mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-11 16:15:33 -06:00
providers/aws: only retry dependency violation for security groups
[GH-436]
This commit is contained in:
parent
b4f8b7f43b
commit
7c89fb06cc
@ -235,16 +235,27 @@ func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) er
|
|||||||
|
|
||||||
log.Printf("[DEBUG] Security Group destroy: %v", d.Id())
|
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()})
|
_, err := ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: d.Id()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec2err, ok := err.(*ec2.Error)
|
ec2err, ok := err.(*ec2.Error)
|
||||||
if ok && ec2err.Code == "InvalidGroup.NotFound" {
|
if !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ec2err.Code {
|
||||||
|
case "InvalidGroup.NotFound":
|
||||||
return nil
|
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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user