This repository was archived by the owner on Jul 11, 2023. It is now read-only.
File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 10
10
*/
11
11
12
12
locals {
13
+ # Variable which controls if NAT and it's dependent resources has to be created or not
13
14
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.
14
16
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 ) : []
16
19
}
17
20
18
21
# AWS Managed NAT Gateways
@@ -34,7 +37,7 @@ data "aws_subnet" "public" {
34
37
resource "aws_nat_gateway" "nat" {
35
38
count = local. total_nat_count
36
39
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 )
38
41
39
42
tags = merge (
40
43
{
You can’t perform that action at this time.
0 commit comments