Skip to content

Commit

Permalink
Merge pull request #9644 from terraform-providers/rfd-retry-vpc
Browse files Browse the repository at this point in the history
Final retry after timeout deleting vpc
  • Loading branch information
ryndaniels authored Aug 7, 2019
2 parents 7ef2a35 + f0fab36 commit a3a294d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions aws/resource_aws_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,26 +478,31 @@ func resourceAwsVpcDelete(d *schema.ResourceData, meta interface{}) error {
}
log.Printf("[INFO] Deleting VPC: %s", d.Id())

return resource.Retry(5*time.Minute, func() *resource.RetryError {
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteVpc(deleteVpcOpts)
if err == nil {
return nil
}

ec2err, ok := err.(awserr.Error)
if !ok {
return resource.NonRetryableError(err)
}

switch ec2err.Code() {
case "InvalidVpcID.NotFound":
if isAWSErr(err, "InvalidVpcID.NotFound", "") {
return nil
case "DependencyViolation":
}
if isAWSErr(err, "DependencyViolation", "") {
return resource.RetryableError(err)
}

return resource.NonRetryableError(fmt.Errorf("Error deleting VPC: %s", err))
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteVpc(deleteVpcOpts)
if isAWSErr(err, "InvalidVpcID.NotFound", "") {
return nil
}
}

if err != nil {
return fmt.Errorf("Error deleting VPC: %s", err)
}
return nil
}

func resourceAwsVpcCustomizeDiff(diff *schema.ResourceDiff, v interface{}) error {
Expand Down

0 comments on commit a3a294d

Please sign in to comment.