cloudposse / terraform-aws-dynamic-subnets

Terraform module for public and private subnets provisioning in existing VPC
https://cloudposse.com/accelerate
Apache License 2.0
197 stars 167 forks source link

Region: ap-northeast-3 does not work. #133

Closed ktasper closed 3 years ago

ktasper commented 3 years ago

Describe the Bug

When trying to use this module with the new ap-northeast-3 region it does not work.

Expected Behavior

I expect it to create the subnets.

Steps to Reproduce

Steps to reproduce the behavior:

provider "aws" {
  region  = var.region
  profile = var.profile
}

module "vpc" {
  source     = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.25.0"
  cidr_block = var.cidr_block
  attributes = ["vpc"]
}

module "subnets" {
  source                          = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.39.0"
  vpc_id                          = module.vpc.vpc_id
  igw_id                          = module.vpc.igw_id
  cidr_block                      = module.vpc.vpc_cidr_block
  availability_zones              = var.az
  aws_route_create_timeout        = "5m"
  aws_route_delete_timeout        = "10m"
}

variable "cidr_block" {
  default = "10.0.0.0/24"
}

variable "region" {
  default = "ap-northeast-3"
}
variable "profile" {
    default = "default" 
}
variable "az" {
  default = ["ap-northeast-3a","ap-northeast-3b","ap-northeast-3c"]
}

Will result in the following error:

╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/nat-gateway.tf line 24, in resource "aws_eip" "default":
│   24:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 2
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/nat-gateway.tf line 24, in resource "aws_eip" "default":
│   24:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 0
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/nat-gateway.tf line 24, in resource "aws_eip" "default":
│   24:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 1
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/private.tf line 33, in resource "aws_subnet" "private":
│   33:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 0
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/private.tf line 33, in resource "aws_subnet" "private":
│   33:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 1
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/private.tf line 33, in resource "aws_subnet" "private":
│   33:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 2
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/private.tf line 50, in resource "aws_route_table" "private":
│   50:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 2
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/private.tf line 50, in resource "aws_route_table" "private":
│   50:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 0
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/private.tf line 50, in resource "aws_route_table" "private":
│   50:       "Name" = format("%s%s%s", module.private_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 1
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/public.tf line 37, in resource "aws_subnet" "public":
│   37:       "Name" = format("%s%s%s", module.public_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 0
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/public.tf line 37, in resource "aws_subnet" "public":
│   37:       "Name" = format("%s%s%s", module.public_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 2
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on .terraform/modules/subnets/public.tf line 37, in resource "aws_subnet" "public":
│   37:       "Name" = format("%s%s%s", module.public_label.id, local.delimiter, local.az_map[element(var.availability_zones, count.index)])
│     ├────────────────
│     │ count.index is 1
│     │ local.az_map is object with 220 attributes
│     │ var.availability_zones is list of string with 3 elements
│ 
│ The given key does not identify an element in this collection value.

Versions

VPC = 0.25.0
Subnets = 0.39.0
Terraform = 0.15.4 
ktasper commented 3 years ago

This PR Fixes it.