I am trying to query the AWS availability zones, but wish to filter the zones based on region hence modified data
block:
locals {
cluster_name = var.my_cluster_name
aws_region = var.my_cluster_region
}
data "aws_availability_zones" "available_zones" {
state = "available"
filter {
name = "region-name"
values = ["${local.aws_region}"]
}
}
When I try to use the same with vpc
block:
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "3.5.0"
name = var.gloo_vpc_name
cidr = "10.0.0.0/16"
azs = data.aws_availability_zones.available_zones.names
...
}
I get the series of errors like,
│
│ on .terraform/modules/gloo-cluster.vpc/main.tf line 1075, in resource "aws_eip" "nat":
│ 1075: element(var.azs, var.single_nat_gateway ? 0 : count.index),
│ ├────────────────
│ │ count.index is 0
│ │ var.azs is empty list of string
│ │ var.single_nat_gateway is true
│
│ Call to function "element" failed: cannot use element function with an empty list.
Is there anything wrong with my filter ?