Error in function call. when trying to associate route tables to subnets

Hi i keep getting an error. Error in function call
Call to function “element” failed: cannot use element function with an empty
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

Hi @davidATsains,

When asking about an error message, it’s helpful to share the entire error message (including the code snippet and the long description) so we can see exactly what part of the configuration the error message is related to. Would you please run this again and share the full error message? Thanks!