From 67d817abd636b40344009d07ade32001a1d0a426 Mon Sep 17 00:00:00 2001 From: TanguyK Date: Wed, 24 Jan 2024 15:00:11 +0100 Subject: [PATCH] s --- locals.tf | 4 ++-- main.tf | 4 ++-- nat_gateway.tf | 8 ++++---- outputs.tf | 2 +- variables.tf | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/locals.tf b/locals.tf index 82c7432..940084a 100644 --- a/locals.tf +++ b/locals.tf @@ -1,4 +1,4 @@ locals { - public_subnets = { for k, v in aws_subnet.quortex : k => v if v.map_public_ip_on_launch == true } - private_subnets = { for k, v in aws_subnet.quortex : k => v if v.map_public_ip_on_launch == false } + public_subnets = { for k, v in aws_subnet.quortex : k => v if v.map_public_ip_on_launch == true } + private_subnets = { for k, v in aws_subnet.quortex : k => v if v.map_public_ip_on_launch == false } } diff --git a/main.tf b/main.tf index 33157f9..c6c28ae 100644 --- a/main.tf +++ b/main.tf @@ -120,7 +120,7 @@ resource "aws_route_table" "quortex_private" { # Route to the NAT, if NAT is enabled... dynamic "route" { - for_each = length([for k, v in aws_nat_gateway.quortex : v if v.subnet_key == each.key])[0] > 0 ? [1] : [] + for_each = length([for k, v in aws_nat_gateway.quortex : v if v.subnet_key == each.key]) > 0 ? [1] : [] content { cidr_block = "0.0.0.0/0" @@ -130,7 +130,7 @@ resource "aws_route_table" "quortex_private" { # ...otherwise, route to the Internet Gateway dynamic "route" { - for_each = length([for k, v in aws_nat_gateway.quortex : v if v.subnet_key == each.key])[0] == 0 ? [1] : [] + for_each = length([for k, v in aws_nat_gateway.quortex : v if v.subnet_key == each.key]) == 0 ? [1] : [] content { cidr_block = "0.0.0.0/0" diff --git a/nat_gateway.tf b/nat_gateway.tf index 61601ab..2bb0c8a 100644 --- a/nat_gateway.tf +++ b/nat_gateway.tf @@ -18,7 +18,7 @@ # A static Elastic IP used for Quortex cluster External NAT Gateway IP. # This resource is created for each nat gateway where no existing EIP is specified. resource "aws_eip" "quortex" { - for_each = {for k,v in var.nat_gateways : k => v if v.eip_allocation_id == null} + for_each = { for k, v in var.nat_gateways : k => v if v.eip_allocation_id == null } tags = merge({ "Name" = each.key }, var.tags) } @@ -26,14 +26,14 @@ resource "aws_eip" "quortex" { # An existing Elastic IP that will be attached to NAT gateways when # the id is defined. This datasource is used only to display the IP address data "aws_eip" "existing_eip" { - for_each = {for k,v in var.nat_gateways : k => v if v.eip_allocation_id != null} + for_each = { for k, v in var.nat_gateways : k => v if v.eip_allocation_id != null } id = each.value.eip_allocation_id } # Nat gateways depending on the list passed in the nat_gateways variable resource "aws_nat_gateway" "quortex" { - for_each = {for k,v in var.nat_gateways : k => v if local.public_subnets[v.subnet_key] != null} + for_each = { for k, v in var.nat_gateways : k => v if local.public_subnets[v.subnet_key] != null } allocation_id = each.value.eip_allocation_id == null ? aws_eip.quortex[each.key].id : data.aws_eip.existing_eip[each.key].id subnet_id = local.public_subnets[each.value.subnet_key].id @@ -44,4 +44,4 @@ resource "aws_nat_gateway" "quortex" { }, var.tags) depends_on = [aws_internet_gateway.quortex] -} \ No newline at end of file +} diff --git a/outputs.tf b/outputs.tf index 6f57ad2..4a17498 100644 --- a/outputs.tf +++ b/outputs.tf @@ -51,7 +51,7 @@ output "route_table_ids_private" { } output "nat_eip_id" { - value = concat(values(aws_eip.quortex[*].id), values({for k,v in var.nat_gateways : k => v if v.eip_allocation_id != null}[*].eip_allocation_id)) + value = concat(values(aws_eip.quortex[*].id), values({ for k, v in var.nat_gateways : k => v if v.eip_allocation_id != null }[*].eip_allocation_id)) description = "The IDs of the Elastic IPs associated to the Quortex cluster External NAT Gateways." } diff --git a/variables.tf b/variables.tf index 4a8d3d5..ad06a87 100644 --- a/variables.tf +++ b/variables.tf @@ -56,7 +56,7 @@ variable "nat_gateway_name_prefix" { } variable "nat_gateways" { - type = map(object({subnet_key = string, eip_allocation_id = string })) + type = map(object({ subnet_key = string, eip_allocation_id = string })) description = <