Hi i keep getting an error. Error in function call
Call to function “element” failed: cannot use element function with an empty
list.
This is my resource.
resource "aws_route_table_association" "private_subnet" {
count = length(var.private_subnets_cidrs) > 0 ? local.max_subnet_length : 0
subnet_id = element(concat(aws_subnet.private.*.id), count.index)
route_table_id = element(aws_route_table.private.*.id, count.index)
}
this is my locals
locals {
max_subnet_length = max(length(var.private_subnets_cidrs))
max_gateway = max(length(var.vpc_gateway_endpoint_services))
}
This is my variable
variable "private_subnets_cidrs" {
description = "The CIDR range for the private subnets"
type = list(string)
default = [""]
}
Please can someone please help me