Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Add documentation comment on newly introduced variables
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi authored and ketzacoatl committed Apr 15, 2020
1 parent 574f7a2 commit d845512
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/nat-gateways/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
*/

locals {
# Variable which controls if NAT and it's dependent resources has to be created or not
total_nat_count = var.enable_nat_creation ? var.nat_count : 0
# Number of new NATs to be created in case var.nat_eip is empty.
total_new_nat = var.enable_nat_creation ? (length(var.nat_eip) == 0 ? local.total_nat_count : 0) : 0
nat_ids = var.enable_nat_creation ? (length(var.nat_eip) == 0 ? aws_eip.nat.*.id : values(data.aws_eip.nat)[*].id) : []
# Gives the EIP ids. It would be either populated via data source or newly created (which is controlled by var.nat_eip).
eip_ids = var.enable_nat_creation ? (length(var.nat_eip) == 0 ? aws_eip.nat.*.id : values(data.aws_eip.nat)[*].id) : []
}

# AWS Managed NAT Gateways
Expand All @@ -34,7 +37,7 @@ data "aws_subnet" "public" {
resource "aws_nat_gateway" "nat" {
count = local.total_nat_count
subnet_id = element(data.aws_subnet.public.*.id, count.index)
allocation_id = element(local.nat_ids, count.index)
allocation_id = element(local.eip_ids, count.index)

tags = merge(
{
Expand Down

0 comments on commit d845512

Please sign in to comment.