_This issue was originally opened by @brikis98 as hashicorp/terraform#8530. It was migrated here as part of the provider split. The original body of the issue is below._
Terraform v0.7.2
The full set of templates is fairly big. It creates a VPC, a number of routes, an internet gateway, nat gateway, network ACLs, peering connections, and so on. The routes for the VPC peering connections are what seem to cause the problem:
resource "aws_vpc_peering_connection" "vpc_peering_connection" {
peer_owner_id = "${var.aws_account_id}"
vpc_id = "${var.origin_vpc_id}"
peer_vpc_id = "${var.destination_vpc_id}"
auto_accept = true
tags { Name = "${var.origin_vpc_name}-to-${var.destination_vpc_name}" }
}
resource "aws_route" "origin_to_destination" {
count = "${var.num_origin_vpc_route_tables}"
route_table_id = "${element(split(",", var.origin_vpc_route_table_ids), count.index)}"
destination_cidr_block = "${var.destination_vpc_cidr_block}"
vpc_peering_connection_id = "${aws_vpc_peering_connection.vpc_peering_connection.id}"
}
Note that this code has not yet been updated to take advantage of first-class support for lists in Terraform 0.7.x. Is it possible that has anything to do with the problem?
In Terraform 0.6.x, this would create the VPC, routes, and peering connections, _usually_ without problems.
On almost every single run with Terraform 0.7.x, I get errors like the following:
* aws_route.origin_to_destination.1: Error creating route: RouteAlreadyExists: The route identified by 10.2.0.0/18 already exists.
status code: 400, request id: 632fc036-ec35-441c-be0e-4616c2ff8067
* aws_route.origin_to_destination.0: Error creating route: RouteAlreadyExists: The route identified by 10.2.0.0/18 already exists.
status code: 400, request id: 90b06123-714c-4037-b604-5043e7b9a2f9
* aws_route.origin_to_destination.2: Error creating route: RouteAlreadyExists: The route identified by 10.2.0.0/18 already exists.
status code: 400, request id: ad67ab36-1d39-4e04-a35a-847195eb80e3
* aws_route.origin_to_destination.3: Error creating route: RouteAlreadyExists: The route identified by 10.2.0.0/18 already exists.
status code: 400, request id: 1db124b2-a7fb-4b2d-a7ec-58ee5c009388
* aws_route.nat.0: Error finding route after creating it: error finding matching route for Route table (rtb-11fd5977) and destination CIDR block (0.0.0.0/0)
Of course, none of these routes actually existed before I ran terraform apply, so there must be some issue with Terraform trying to create them twice.
terraform applyWill this ever get resolved? I think routes ought to be cleared.
@tariq1890 Are you still having this problem?