terraform-aws-modules / terraform-aws-vpc

Terraform module to create AWS VPC resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws
Apache License 2.0
2.99k stars 4.44k forks source link

unable to create a VPC with only 1 private subnet without nat gateway #927

Closed Raghav2211 closed 1 year ago

Raghav2211 commented 1 year ago

Description

want to test VPC peering between two VPC in same region for that i want to create a VPC with only 1 private subnet without nat instance or nat gateway but I'm getting below error

.terraform/modules/vpc/main.tf line 273, in resource "aws_route_table_association" "private":
│  273:   route_table_id = element(
│  274:     aws_route_table.private[*].id,
│  275:     var.single_nat_gateway ? 0 : count.index,
│  276:   )
│     ├────────────────
│     │ aws_route_table.private 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.

main.tf

module "vpc" {
  source   = "terraform-aws-modules/vpc/aws"
  version  = "4.0.0"

  name                           = "vpc-a"
  cidr                              = 10.0.0.0/16
  azs                               = ["ap-south-1"]
  private_subnets          = ["10.0.0.0.0/24"]
  enable_nat_gateway  = false
  #single_nat_gateway  = false
}
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.