providers/aws: retry deleting security group for some time [GH-436]

This commit is contained in:
Mitchell Hashimoto 2014-10-17 18:21:10 -07:00
parent 990b814188
commit 10ce2b690c
2 changed files with 12 additions and 7 deletions

View File

@ -13,6 +13,9 @@ BUG FIXES:
the correct data and don't incorrectly recreate themselves. [GH-425] the correct data and don't incorrectly recreate themselves. [GH-425]
* providers/aws: Fix case where ELB would incorrectly plan to modify * providers/aws: Fix case where ELB would incorrectly plan to modify
listeners (with the same data) in some cases. listeners (with the same data) in some cases.
* providers/aws: Retry deleting security groups for some amount of time
if there is a dependency violation since it is probably just eventual
consistency. [GH-436]
## 0.3.0 (October 14, 2014) ## 0.3.0 (October 14, 2014)

View File

@ -235,15 +235,17 @@ 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())
_, err := ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: d.Id()}) return resource.Retry(5 * time.Minute, func() error {
if err != nil { _, err := ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: d.Id()})
ec2err, ok := err.(*ec2.Error) if err != nil {
if ok && ec2err.Code == "InvalidGroup.NotFound" { ec2err, ok := err.(*ec2.Error)
return nil if ok && ec2err.Code == "InvalidGroup.NotFound" {
return nil
}
} }
}
return err return err
})
} }
func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) error { func resourceAwsSecurityGroupRead(d *schema.ResourceData, meta interface{}) error {