Skip to content

Commit

Permalink
Merge pull request #8752 from terraform-providers/f-aws_ec2_transit_g…
Browse files Browse the repository at this point in the history
…ateway-dx-attachments

resource/aws_ec2_transit_gateway: Add retry on DirectConnect Attachments error
  • Loading branch information
nywilken authored May 23, 2019
2 parents 9e5adf3 + 58c3d76 commit 47f8d35
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion aws/resource_aws_ec2_transit_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,17 @@ func resourceAwsEc2TransitGatewayDelete(d *schema.ResourceData, meta interface{}
}

log.Printf("[DEBUG] Deleting EC2 Transit Gateway (%s): %s", d.Id(), input)
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteTransitGateway(input)

if isAWSErr(err, "IncorrectState", "has non-deleted Transit Gateway Attachments") {
return resource.RetryableError(err)
}

if isAWSErr(err, "IncorrectState", "has non-deleted DirectConnect Gateway Attachments") {
return resource.RetryableError(err)
}

if isAWSErr(err, "IncorrectState", "has non-deleted VPN Attachments") {
return resource.RetryableError(err)
}
Expand All @@ -233,6 +237,10 @@ func resourceAwsEc2TransitGatewayDelete(d *schema.ResourceData, meta interface{}
return nil
})

if isResourceTimeoutError(err) {
_, err = conn.DeleteTransitGateway(input)
}

if isAWSErr(err, "InvalidTransitGatewayID.NotFound", "") {
return nil
}
Expand Down

0 comments on commit 47f8d35

Please sign in to comment.