Trouble with cidr_block and aws_subnet - aws_subnet.RdsSubnet is tuple with 2 elements

I am trying to conditionally create an Rds Subnet Group with two private subnets. I keep getting errors regarding the cidr_block, aws_subnet, and availability zones. changing one to “fix” it results in an error in the other two. with the current code below, I’m getting this error:

Error: Error in function call

│ on network.tf line 181, in resource “aws_route_table_association” “PrivateTableAssoc”:
│ 181: subnet_id = values(aws_subnet.RdsSubnet)[*].id # [aws_subnet.RdsSubnet1.id, aws_subnet.RdsSubnet2.id] #[aws_subnet.RdsSubnet1[count.index].id, aws_subnet.RdsSubnet2[count.index].id] #aws_subnet.RdsSubnet[0,1].id
│ ├────────────────
│ │ aws_subnet.RdsSubnet is tuple with 2 elements

│ Call to function “values” failed: values() requires a map as the first argument.

My code below contains several lines commented out for most entries, from different ways I’ve tried to implement this. If anyone can provide any guidance here, it would be very much appreciated! I’ve been banging my head against the wall for a week.

#-------------------------------------------------------
###Create VPC in us-east-1
#-------------------------------------------------------

resource “aws_vpc” “X360-VPC” {
provider = aws.region-main
cidr_block = “10.0.0.0/26”
enable_dns_support = true
enable_dns_hostnames = true
tags = {
Name = “X360 VPC”
}
}

#-------------------------------------------------------
###Create Internet Gateway
#-------------------------------------------------------

resource “aws_internet_gateway” “IGW” {
provider = aws.region-main
vpc_id = aws_vpc.X360-VPC.id
}

#-------------------------------------------------------
###Create NAT Gateway
#-------------------------------------------------------

resource “aws_eip” “NATEIP” {
provider = aws.region-main
count = var.RdsCreate ? 1 : 0
vpc = true
depends_on = [aws_internet_gateway.IGW]
}

resource “aws_nat_gateway” “NAT” {
count = var.RdsCreate ? 1 : 0
provider = aws.region-main
allocation_id = aws_eip.NATEIP[0].id #aws_eip.NATEIP[count.index].id
subnet_id = aws_subnet.X360Subnet1.id
depends_on = [aws_internet_gateway.IGW]
}

#-------------------------------------------------------
###Populate list of AZs into the azs variable
#-------------------------------------------------------

data “aws_availability_zones” “azs” {
provider = aws.region-main
state = “available”
}

#-------------------------------------------------------
###Replace the default route table that was created for the X360-VPC
#-------------------------------------------------------
#NOTE: This overwrites the default route table created for the VPC.
#If this replacement route_table were deleted from the tf, the default route table will still work.

resource “aws_route_table” “VpcTable” {
provider = aws.region-main
vpc_id = aws_vpc.X360-VPC.id
route {
cidr_block = “0.0.0.0/0”
gateway_id = aws_internet_gateway.IGW.id
}
lifecycle {
ignore_changes = all
}
tags = {
Name = “VPC_Route_Table”
}
}

resource “aws_main_route_table_association” “set-VPC_Route_Table-default-assoc” {
provider = aws.region-main
vpc_id = aws_vpc.X360-VPC.id
route_table_id = aws_route_table.VpcTable.id
}

#-------------------------------------------------------
###Create Public Subnet for X360 Application
#-------------------------------------------------------

resource “aws_subnet” “X360Subnet1” {
provider = aws.region-main
availability_zone = element(data.aws_availability_zones.azs.names, 0)
vpc_id = aws_vpc.X360-VPC.id
cidr_block = “10.0.0.0/28”
tags = {
Name = “X360Subnet1-public”
}
}

resource “aws_route_table” “PublicSubnetTable” {
provider = aws.region-main
vpc_id = aws_vpc.X360-VPC.id
route {
cidr_block = “0.0.0.0/0”
gateway_id = aws_internet_gateway.IGW.id
}
tags = {
Name = “PublicSubnetRouteTable”
}
}

resource “aws_route_table_association” “PublicTableAssoc” {
provider = aws.region-main
subnet_id = aws_subnet.X360Subnet1.id
route_table_id = aws_route_table.PublicSubnetTable.id
}

#-------------------------------------------------------
###Create Private Subnets for RDS
#-------------------------------------------------------

resource “aws_subnet” “RdsSubnet” {
#count = “{var.RdsCreate ? length(var.RdsSubnetsCidrs) : 0}" #index = index(var.RdsSubnetsCidrs, *) #count = 2 #count = var.RdsCreate ? 2 : 0 count = "{length(var.RdsSubnetsCidrs)}”
provider = aws.region-main
availability_zone = “{element(data.aws_availability_zones.azs.names, count.index)}" #"{data.aws_availability_zones.azs.names[count.index]}” #element(data.aws_availability_zones.azs.names, 0)
vpc_id = aws_vpc.X360-VPC.id
cidr_block = “{element(var.RdsSubnetsCidrs, count.index)}" #["{var.RdsSubnetsCidrs}”] #element(var.RdsSubnetsCidrs[count.index].rendered) #["{var.RdsSubnetsCidrs}"] #"{slice(var.RdsSubnetsCidrs, 0, 1)}"
depends_on = [aws_eip.NATEIP]
tags = {
Name = “X360RdsSubnet[count.index]-private”
}
}

#resource “aws_subnet” “RdsSubnet1” {
#count = var.RdsCreate ? 1 : 0
#provider = aws.region-main
#availability_zone = element(data.aws_availability_zones.azs.names, 0)
#vpc_id = aws_vpc.X360-VPC.id
#cidr_block = “10.0.0.16/28”
#depends_on = [aws_eip.NATEIP]
#tags = {
#Name = “X360RdsSubnet1-private”
#}
#}

#resource “aws_subnet” “RdsSubnet2” {
#count = var.RdsCreate ? 1 : 0
#provider = aws.region-main
#availability_zone = element(data.aws_availability_zones.azs.names, 1)
#vpc_id = aws_vpc.X360-VPC.id
#cidr_block = “10.0.0.32/28”
#depends_on = [aws_eip.NATEIP]
#tags = {
#Name = “X360RdsSubnet2-private”
#}
#}

resource “aws_route_table” “PrivateSubnetTable” {
#count = var.RdsCreate ? 1 : 0
provider = aws.region-main
vpc_id = aws_vpc.X360-VPC.id
route {
cidr_block = “0.0.0.0/0”
nat_gateway_id = aws_nat_gateway.NAT[0].id #aws_nat_gateway.NAT[count.index].id
}
depends_on = [aws_eip.NATEIP]
tags = {
Name = “PrivateSubnetRouteTable”
}
}

resource “aws_route_table_association” “PrivateTableAssoc” {
#count = var.RdsCreate ? 1 : 0
provider = aws.region-main
subnet_id = values(aws_subnet.RdsSubnet)[*].id # [aws_subnet.RdsSubnet1.id, aws_subnet.RdsSubnet2.id] #[aws_subnet.RdsSubnet1[count.index].id, aws_subnet.RdsSubnet2[count.index].id] #aws_subnet.RdsSubnet[0,1].id
route_table_id = aws_route_table.PrivateSubnetTable.id #aws_route_table.PrivateSubnetTable[0].id
depends_on = [aws_eip.NATEIP]

}

#-------------------------------------------------------
###Create Subnet Group for RDS
#-------------------------------------------------------

resource “aws_db_subnet_group” “RdsSubnetGroup” {
count = var.RdsCreate ? 1 : 0
provider = aws.region-main
name = “x360rdssubnetgroup”
subnet_ids = values(aws_subnet.RdsSubnet)[*].id #[aws_subnet.RdsSubnet1.id, aws_subnet.RdsSubnet2.id] #[aws_subnet.RdsSubnet1[0].id, aws_subnet.RdsSubnet2[0].id]
}