-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Milestone
@nodesocket
Description
Description
Hello. I had a previous VPC defined using:
module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "3.2.0" name = "vpc-stage" cidr = "192.168.0.0/18" azs = data.aws_availability_zones.usw2.names public_subnets = [ "192.168.0.0/20", "192.168.16.0/20", "192.168.32.0/20", ] enable_nat_gateway = true enable_vpn_gateway = false enable_dns_support = true enable_dns_hostnames = true tags = { Terraform = "true" Environment = "stage" } public_subnet_tags = { "kubernetes.io/cluster/acme-org-stage" = "owned" } }
Trying to create a new VPC alongside the existing VPC using the following:
module "vpc_nat" { source = "terraform-aws-modules/vpc/aws" version = "3.2.0" name = "vpc-nat-stage" cidr = "10.0.0.0/16" azs = data.aws_availability_zones.usw2.names private_subnets = [ "10.0.0.0/20", "10.0.16.0/20", "10.0.32.0/20" ] public_subnets = [ "10.0.48.0/20", "10.0.64.0/20", "10.0.80.0/20" ] enable_nat_gateway = true single_nat_gateway = false one_nat_gateway_per_az = true enable_vpn_gateway = false enable_dns_support = true enable_dns_hostnames = true reuse_nat_ips = true external_nat_ip_ids = aws_eip.nat.*.id private_subnet_tags = { Private = true "kubernetes.io/cluster/acme-org-stage" = "owned" } public_subnet_tags = { Private = false } tags = { Terraform = "true" Environment = "stage" } }
But it is erroring inside of the this module with:
│ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1090, in resource "aws_nat_gateway" "this": │ 1090: subnet_id = element( │ 1091: aws_subnet.public.*.id, │ 1092: var.single_nat_gateway ? 0 : count.index, │ 1093: ) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 0 │ │ var.single_nat_gateway is false │ │ Call to function "element" failed: cannot use element function with an empty list. ╵ ╷ │ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1090, in resource "aws_nat_gateway" "this": │ 1090: subnet_id = element( │ 1091: aws_subnet.public.*.id, │ 1092: var.single_nat_gateway ? 0 : count.index, │ 1093: ) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 1 │ │ var.single_nat_gateway is false │ │ Call to function "element" failed: cannot use element function with an empty list. ╵ ╷ │ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1090, in resource "aws_nat_gateway" "this": │ 1090: subnet_id = element( │ 1091: aws_subnet.public.*.id, │ 1092: var.single_nat_gateway ? 0 : count.index, │ 1093: ) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 2 │ │ var.single_nat_gateway is false │ │ Call to function "element" failed: cannot use element function with an empty list. ╵ ╷ │ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1090, in resource "aws_nat_gateway" "this": │ 1090: subnet_id = element( │ 1091: aws_subnet.public.*.id, │ 1092: var.single_nat_gateway ? 0 : count.index, │ 1093: ) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 3 │ │ var.single_nat_gateway is false │ │ Call to function "element" failed: cannot use element function with an empty list. ╵ ╷ │ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1207, in resource "aws_route_table_association" "public": │ 1207: subnet_id = element(aws_subnet.public.*.id, count.index) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 0 │ │ Call to function "element" failed: cannot use element function with an empty list. ╵ ╷ │ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1207, in resource "aws_route_table_association" "public": │ 1207: subnet_id = element(aws_subnet.public.*.id, count.index) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 2 │ │ Call to function "element" failed: cannot use element function with an empty list. ╵ ╷ │ Error: Error in function call │ │ on .terraform/modules/vpc_nat/main.tf line 1207, in resource "aws_route_table_association" "public": │ 1207: subnet_id = element(aws_subnet.public.*.id, count.index) │ ├──────────────── │ │ aws_subnet.public is empty tuple │ │ count.index is 1 │ │ Call to function "element" failed: cannot use element function with an empty list.
Versions
- Terraform:
v1.0.4 - Provider(s):
+ provider registry.terraform.io/hashicorp/aws v3.48.0 + provider registry.terraform.io/hashicorp/cloudinit v2.2.0 + provider registry.terraform.io/hashicorp/kubernetes v1.13.4 + provider registry.terraform.io/hashicorp/local v2.1.0 + provider registry.terraform.io/hashicorp/random v3.1.0 + provider registry.terraform.io/terraform-aws-modules/http v2.4.1
- AWS VPC Module:
3.2.0
Reproduction
Steps to reproduce the behavior:
Not using workspaces. I tried rm -rf .terraform && terraform init && terraform plan but the error is consistent.
Code Snippet to Reproduce
terraform plan
Metadata
Metadata
Assignees
Labels
No labels