Terraform Route Table 强制每次申请新资源

Terraform Route Table forcing new resource every apply

如有知道的请提前致谢!

当我像这样为跨账户 vpc 对等添加多个子网的路由时,它会在每次应用时强制一个新资源

resource "aws_route" "route" {
  count                     = "${var.first_route_table_count}"
  route_table_id            = "${element(var.first_route_table_ids, count.index)}"
  destination_cidr_block    = "${data.aws_vpc.second_vpc.cidr_block}"
  vpc_peering_connection_id = "${aws_vpc_peering_connection.peer.id}"
}

resource "aws_route" "second_account_route" {
  provider                  = "aws.second_account"
  count                     = "${var.second_route_table_count}"
  route_table_id            = "${element(var.second_route_table_ids, count.index)}"
  destination_cidr_block    = "${data.aws_vpc.first_vpc.cidr_block}"
  vpc_peering_connection_id = "${aws_vpc_peering_connection.peer.id}"
}

如果以后有人遇到这个 Terraform 怪癖,这里是解决方案..

我开始意识到,因为我同时定义了一条路线 table 和一条路线,所以您以后不能添加另一条路线。

解决方法是创建一个没有路由的路由 table,然后单独添加所有其他路由。