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

Commit d845512

Browse files
psibiketzacoatl
authored andcommitted
Add documentation comment on newly introduced variables
1 parent 574f7a2 commit d845512

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/nat-gateways/main.tf

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
*/
1111

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

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

3942
tags = merge(
4043
{

0 commit comments

Comments
 (0)