Closed
Description
I am creating a module to setup VPC peering between any two given VPCs. The module defines the following:
resource "aws_route" "vpc_to_peer_vpc" {
count = "${length(split(",", var.vpc_route_table_ids))}"
route_table_id = "${element(split(",", var.vpc_route_table_ids), count.index)}"
destination_cidr_block = "${var.peer_vpc_cidr}"
vpc_peering_connection_id = "${aws_vpc_peering_connection.main.id}"
}
resource "aws_route" "peer_vpc_to_vpc" {
count = "${length(split(",", var.peer_vpc_route_table_ids))}"
route_table_id = "${element(split(",", var.peer_vpc_route_table_ids), count.index)}"
destination_cidr_block = "${var.vpc_cidr}"
vpc_peering_connection_id = "${aws_vpc_peering_connection.main.id}"
}
When I run terraform plan
, I get the following error:
There are warnings and/or errors related to your configuration. Please
fix these before continuing.
Errors:
* strconv.ParseInt: parsing "${length(split(\",\", var.peer_vpc_route_table_ids))}": invalid syntax
* strconv.ParseInt: parsing "${length(split(\",\", var.vpc_route_table_ids))}": invalid syntax
I cannot for the life of me figure out the syntax error (if there even is one). I checked the Interpolation docs and as far as I can tell, it follows the examples.
Is this just a problem because of count
and a very poor error message? Any advice appreciated! Thanks.