嗨,我一直遇到错误。
我得到的错误:
Error: Error in function call
on vpc.tf line 57, in resource "aws_route_table_association" "private_subnet":
57: subnet_id = element(aws_subnet.private.*.id, count.index)
|----------------
| aws_subnet.private is empty tuple
| count.index is 1
Call to function "element" failed: cannot use element function with an empty
list.
variable "private_subnets_cidrs" {
description = "The CIDR range for the private subnets"
type = list(string)
}
我添加了我的子网和路由表关联资源,供您检查。
resource "aws_subnet" "private" {
count = local.max_subnet_length
vpc_id = aws_vpc.proxy_vpc.id
cidr_block = var.private_subnets_cidrs[count.index]
availability_zone = element(var.azs, count.index)
}
private_subnets_cidrs = ["10.9.*.*/2*", "10.9.*.*/2*"]
resource "aws_route_table_association" "private_subnet" {
count = length(var.private_subnets_cidrs) > 0 ? length(var.private_subnets_cidrs) : 0
subnet_id = element(concat(aws_subnet.private.*.id), count.index)
route_table_id = element(aws_route_table.private.*.id, count.index)
}
请有人可以帮助我。 我该如何解决?我希望能够将每个子网与每个路由表相关联