grem11n / terraform-aws-vpc-peering

Terraform module to setup VPC peering connection
https://registry.terraform.io/modules/grem11n/vpc-peering/aws/latest
Apache License 2.0
126 stars 91 forks source link

[BUG] Switching between peer to peer associated routes causes deadlock #107

Open phene opened 1 year ago

phene commented 1 year ago

Describe the bug If this module has been deployed before with from_peer_associated = false and subsequently run with from_peer_associated = true, the invocation gets into a deadlock. This occurs because both aws_route.peer_routes and aws_route.peer_associated_routes resources would create routes for the VPC's main CIDR. Because of TF's parallelism and the lack of strict ordering between these resources, aws_routes.peer_routes may trigger deletion of the route, then wait for it to be deleted, while aws_route.peer_associated_routes attempts to recreate the route at the same time. If aws_route.peer_associated_routes creates the route before aws_routes.peer_routes sees the route as destroyed, the TF invocation will time out waiting for the route to be desroyed.

Terraform version: 1.5.3

Module version: 6.0.0

Error message: Timeout waiting for aws_route.peer_routes to be destroyed

Workaround: Had to rerun terraform plan + apply 2 more times to get it into a good state.

First run: deletes the routes for aws_route.peer_routes, even though they were created by aws_route.peer_associated_routes. Second run: create the routes for aws_route.peer_associated_routes since now they are missing.