Hello, I’ve a situation. I’ve created a aws client vpn endpoint
, but when I’m trying to assign a route
for each subnet, somehow it couldn’t iterate though all provided route(s)
–
Here is the code:
resource "aws_ec2_client_vpn_route" "endpoint" {
for_each = { for id, subnet in var.subnet : id => subnet }
target_vpc_subnet_id = each.value
client_vpn_endpoint_id = aws_ec2_client_vpn_endpoint.endpoint[0].id
destination_cidr_block = element(var.routes, each.key))
}
The variables:
variable "subnet" {
description = "ID(s) of subnet(s)"
type = list(string)
default = [ "subnet-0xxxA", "subnet-0xxxB", "subnet-0xxxC" ]
}
variable "routes" {
description = "Provided route(s)"
type = list(string)
default = [ "0.0.0.0/0", "10.0.0.0/16" ]
}
–
Expecting: For each provided subnet, assign each provided route.
Got: Only 3 routes are creating, and with random behaviour