Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic subnet names aren't being assigned #1160

Open
1 task
talorlik opened this issue Jan 27, 2025 · 0 comments
Open
1 task

Dynamic subnet names aren't being assigned #1160

talorlik opened this issue Jan 27, 2025 · 0 comments

Comments

@talorlik
Copy link

Description

This line: format("${var.name}-${var.private_subnet_suffix}-%s", element(var.azs, count.index)) doesn't assign the names correctly even though the var.private_subnet_suffix has been assigned. It only takes the name of the VPC and that's it.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]: 5.17.0
  • Terraform version: v1.9.8
  • Provider version(s): v5.82.2

Reproduction Code [Required]

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "5.17.0"
  name    = local.vpc_name
  cidr    = var.vpc_cidr
  azs     = local.azs
  private_subnets = flatten([
    for k, v in local.azs : [
      cidrsubnet(var.vpc_cidr, 4, k * 2),
      cidrsubnet(var.vpc_cidr, 4, k * 2 + 1)
    ]
  ])
  private_subnet_suffix = "subnet"

  create_database_subnet_group  = false
  manage_default_network_acl    = false
  manage_default_route_table    = false
  manage_default_security_group = false

  enable_dns_hostnames = true
  enable_dns_support   = true

  enable_dhcp_options      = true
  dhcp_options_domain_name = "${var.region}.compute.internal"

  single_nat_gateway     = true
  create_igw             = false
  create_egress_only_igw = false

  private_route_table_tags = {
    Name = local.route_table_name
  }
  tags = {
    Name = local.vpc_name
  }
}

Expected behavior

I'd expect the names of the 4 subnets, 2 in each AZ to be as follows (in my case):

  • vpc-qa-subnet-1
  • vpc-qa-subnet-2
  • vpc-qa-subnet-3
  • vpc-qa-subnet-4

Actual behavior

  • vpc-qa
  • vpc-qa
  • vpc-qa
  • vpc-qa

If this can please be sorted out that would be highly appreciated.

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant