From 4ab662419636cd36b0b565aa7beb478fc7479215 Mon Sep 17 00:00:00 2001 From: jarpat Date: Thu, 5 Oct 2023 16:08:44 -0400 Subject: [PATCH] update locals.tf to modify az behavior --- docs/CONFIG-VARS.md | 2 +- locals.tf | 28 +++------------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/docs/CONFIG-VARS.md b/docs/CONFIG-VARS.md index 1929715d..d693df86 100644 --- a/docs/CONFIG-VARS.md +++ b/docs/CONFIG-VARS.md @@ -86,7 +86,7 @@ You can use `default_public_access_cidrs` to set a default range for all created | :--- | ---: | ---: | ---: | ---: | | vpc_cidr | Address space for the VPC | string | "192.168.0.0/16" | This variable is ignored when `vpc_id` is set (AKA bring your own VPC). | | subnets | Subnets to be created and their settings | map | See below for default values | This variable is ignored when `subnet_ids` is set (AKA bring your own subnets). All defined subnets must exist within the VPC address space. | - | subnet_azs | Configure specific AZs you want the subnets to created in. The values must be distinct | optional map | {} see below for an example | If not defined or if not enough zones are listed to match the definitions in `subnets`, the code will perform a lookup to get a list of AZs in your selected region. This variable is ignored when `subnet_ids` is set (AKA bring your own subnets).| + | subnet_azs | Configure specific AZs you want the subnets to created in. The values must be distinct | optional map | {} see below for an example | If not defined or if any keys are not defined, the code will perform a lookup to get a list of AZs in your selected region. This variable is ignored when `subnet_ids` is set (AKA bring your own subnets).| The default values for the subnets variable are as follows: diff --git a/locals.tf b/locals.tf index a8eff1bc..b2c31ae8 100755 --- a/locals.tf +++ b/locals.tf @@ -33,31 +33,9 @@ locals { # Generate list of AZ where created subnets should be placed # If not specified by the user replace with list of all AZs in a region - # If not enough regions provided, append with the list of all AZs in the region while retaining - # order of user provided list of regions - public_subnet_azs = ( - can(var.subnet_azs["public"]) ? - (length(var.subnet_azs["public"]) >= length(lookup(var.subnets, "public", [])) ? - var.subnet_azs["public"] - : distinct(concat(var.subnet_azs["public"], data.aws_availability_zones.available.names))) - : data.aws_availability_zones.available.names - ) - - private_subnet_azs = ( - can(var.subnet_azs["private"]) ? - (length(var.subnet_azs["private"]) >= length(lookup(var.subnets, "private", [])) ? - var.subnet_azs["private"] - : distinct(concat(var.subnet_azs["private"], data.aws_availability_zones.available.names))) - : data.aws_availability_zones.available.names - ) - - database_subnet_azs = ( - can(var.subnet_azs["database"]) ? - (length(var.subnet_azs["database"]) >= length(lookup(var.subnets, "database", [])) ? - var.subnet_azs["database"] - : distinct(concat(var.subnet_azs["database"], data.aws_availability_zones.available.names))) - : data.aws_availability_zones.available.names - ) + public_subnet_azs = can(var.subnet_azs["public"]) ? var.subnet_azs["public"] : data.aws_availability_zones.available.names + private_subnet_azs = can(var.subnet_azs["private"]) ? var.subnet_azs["private"] : data.aws_availability_zones.available.names + database_subnet_azs = can(var.subnet_azs["database"]) ? var.subnet_azs["database"] : data.aws_availability_zones.available.names ssh_public_key = (var.create_jump_vm || var.storage_type == "standard" ? file(var.ssh_public_key)