provider/aws: vpc delete retry on dependency violation [GH-1628]
This commit is contained in:
parent
e5a9cee5bb
commit
ad408d8862
|
@ -258,16 +258,29 @@ func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
VPCID: &vpcID,
|
||||
}
|
||||
log.Printf("[INFO] Deleting VPC: %s", d.Id())
|
||||
if _, err := conn.DeleteVPC(DeleteVpcOpts); err != nil {
|
||||
|
||||
return resource.Retry(5*time.Minute, func() error {
|
||||
_, err := conn.DeleteVPC(DeleteVpcOpts)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
ec2err, ok := err.(awserr.Error)
|
||||
if ok && ec2err.Code() == "InvalidVpcID.NotFound" {
|
||||
return nil
|
||||
if !ok {
|
||||
return &resource.RetryError{Err: err}
|
||||
}
|
||||
|
||||
return fmt.Errorf("Error deleting VPC: %s", err)
|
||||
switch ec2err.Code() {
|
||||
case "InvalidVpcID.NotFound":
|
||||
return nil
|
||||
case "DependencyViolation":
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return &resource.RetryError{
|
||||
Err: fmt.Errorf("Error deleting VPC: %s", err),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// VPCStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
|
|
Loading…
Reference in New Issue