Skip to content

Commit

Permalink
us az ids
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Feb 8, 2020
1 parent 27643f0 commit aedae35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 12 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aedae35

Please sign in to comment.