From aedae35e019e8ae2bca0fa49f62e967f1fa877e5 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Thu, 5 Dec 2019 17:52:34 +0200 Subject: [PATCH] us az ids --- main.tf | 18 ++++++++++++------ variables.tf | 6 ++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 396afb323..677b1beab 100644 --- a/main.tf +++ b/main.tf @@ -285,7 +285,8 @@ resource "aws_subnet" "public" { vpc_id = local.vpc_id cidr_block = element(concat(var.public_subnets, [""]), count.index) - availability_zone = element(var.azs, count.index) + availability_zone = var.use_az_ids == false ? element(var.azs, count.index) : null + availability_zone_id = var.use_az_ids ? element(var.azs, count.index) : null map_public_ip_on_launch = var.map_public_ip_on_launch assign_ipv6_address_on_creation = var.public_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.public_subnet_assign_ipv6_address_on_creation @@ -312,7 +313,8 @@ resource "aws_subnet" "private" { vpc_id = local.vpc_id cidr_block = var.private_subnets[count.index] - availability_zone = element(var.azs, count.index) + availability_zone = var.use_az_ids == false ? element(var.azs, count.index) : null + availability_zone_id = var.use_az_ids ? element(var.azs, count.index) : null assign_ipv6_address_on_creation = var.private_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.private_subnet_assign_ipv6_address_on_creation ipv6_cidr_block = var.enable_ipv6 && length(var.private_subnet_ipv6_prefixes) > 0 ? cidrsubnet(aws_vpc.this[0].ipv6_cidr_block, 8, var.private_subnet_ipv6_prefixes[count.index]) : null @@ -338,7 +340,8 @@ resource "aws_subnet" "database" { vpc_id = local.vpc_id cidr_block = var.database_subnets[count.index] - availability_zone = element(var.azs, count.index) + availability_zone = var.use_az_ids == false ? element(var.azs, count.index) : null + availability_zone_id = var.use_az_ids ? element(var.azs, count.index) : null assign_ipv6_address_on_creation = var.database_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.database_subnet_assign_ipv6_address_on_creation ipv6_cidr_block = var.enable_ipv6 && length(var.database_subnet_ipv6_prefixes) > 0 ? cidrsubnet(aws_vpc.this[0].ipv6_cidr_block, 8, var.database_subnet_ipv6_prefixes[count.index]) : null @@ -380,7 +383,8 @@ resource "aws_subnet" "redshift" { vpc_id = local.vpc_id cidr_block = var.redshift_subnets[count.index] - availability_zone = element(var.azs, count.index) + availability_zone = var.use_az_ids == false ? element(var.azs, count.index) : null + availability_zone_id = var.use_az_ids ? element(var.azs, count.index) : null assign_ipv6_address_on_creation = var.redshift_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.redshift_subnet_assign_ipv6_address_on_creation ipv6_cidr_block = var.enable_ipv6 && length(var.redshift_subnet_ipv6_prefixes) > 0 ? cidrsubnet(aws_vpc.this[0].ipv6_cidr_block, 8, var.redshift_subnet_ipv6_prefixes[count.index]) : null @@ -422,7 +426,8 @@ resource "aws_subnet" "elasticache" { vpc_id = local.vpc_id cidr_block = var.elasticache_subnets[count.index] - availability_zone = element(var.azs, count.index) + availability_zone = var.use_az_ids == false ? element(var.azs, count.index) : null + availability_zone_id = var.use_az_ids ? element(var.azs, count.index) : null assign_ipv6_address_on_creation = var.elasticache_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.elasticache_subnet_assign_ipv6_address_on_creation ipv6_cidr_block = var.enable_ipv6 && length(var.elasticache_subnet_ipv6_prefixes) > 0 ? cidrsubnet(aws_vpc.this[0].ipv6_cidr_block, 8, var.elasticache_subnet_ipv6_prefixes[count.index]) : null @@ -456,7 +461,8 @@ resource "aws_subnet" "intra" { vpc_id = local.vpc_id cidr_block = var.intra_subnets[count.index] - availability_zone = element(var.azs, count.index) + availability_zone = var.use_az_ids == false ? element(var.azs, count.index) : null + availability_zone_id = var.use_az_ids ? element(var.azs, count.index) : null assign_ipv6_address_on_creation = var.intra_subnet_assign_ipv6_address_on_creation == null ? var.assign_ipv6_address_on_creation : var.intra_subnet_assign_ipv6_address_on_creation ipv6_cidr_block = var.enable_ipv6 && length(var.intra_subnet_ipv6_prefixes) > 0 ? cidrsubnet(aws_vpc.this[0].ipv6_cidr_block, 8, var.intra_subnet_ipv6_prefixes[count.index]) : null diff --git a/variables.tf b/variables.tf index 856e2a25c..48d2585f5 100644 --- a/variables.tf +++ b/variables.tf @@ -244,6 +244,12 @@ variable "azs" { default = [] } +variable "use_az_ids" { + description = "Whether to use availability zone ids" + type = bool + default = false +} + variable "enable_dns_hostnames" { description = "Should be true to enable DNS hostnames in the VPC" type = bool