@@ -3,11 +3,21 @@ locals {
3
3
4
4
# references to module.calculate_subnets output
5
5
calculated_subnets = module. calculate_subnets . subnets_by_type
6
- subnet_keys = keys (var. subnets )
7
6
8
- # default names if no name_prefix is passed
7
+ # #################################################################
8
+ # Subnet names
9
+ # A subnet's name is the subnet key by default but can be overrided by `name_prefix`.
10
+ # Subnet names are used for Name tags.
11
+ # resource name labels always use subnet key
12
+ subnet_keys = keys (var. subnets )
9
13
subnet_names = { for type , v in var . subnets : type => try (v. name_prefix , type) }
10
14
15
+ # #################################################################
16
+ # Internal variables for mapping user input from var.subnets to HCL useful values
17
+ # Notes:
18
+ # - subnets map contains arbitrary amount of subnet "keys" which are both defined as the subnets type and default name (unless name_prefix is provided).
19
+ # - resource name labels for subnet use the key as private subnet keys are constructed
20
+
11
21
singleton_subnet_types = [" public" , " transit_gateway" ]
12
22
private_subnet_names = setsubtract (local. subnet_keys , local. singleton_subnet_types )
13
23
@@ -21,7 +31,8 @@ locals {
21
31
private_subnets_tgw_routed = [for type in local . private_subnet_names : type if can (var. subnets [type ]. route_to_transit_gateway )]
22
32
private_subnet_key_names_tgw_routed = [for subnet in local . private_per_az : subnet if contains (local. private_subnets_tgw_routed , split (" /" , subnet)[0 ])]
23
33
24
- # NAT configurations options, selected based on nat_gateway_configuration
34
+ # #################################################################
35
+ # NAT configurations options, maps user string input to HCL usable values. selected based on nat_gateway_configuration
25
36
# null = none
26
37
# all = local.azs
27
38
# single = local.azs[0]
@@ -34,6 +45,13 @@ locals {
34
45
# options defined by `local.nat_options`
35
46
nat_configuration = contains (local. subnet_keys , " public" ) ? local. nat_options [try (var. subnets . public . nat_gateway_configuration , " none" )] : local. nat_options [" none" ]
36
47
48
+
49
+ # #################################################################
50
+ # Feature toggles for whether:
51
+ # - create or reference a VPC
52
+ # - get cidr block value from AWS IPAM
53
+ # - create flow logs
54
+
37
55
# # if var.vpc_id is passed, assume create = `false` and cidr comes from data.aws_vpc
38
56
create_vpc = var. vpc_id == null ? true : false
39
57
vpc = local. create_vpc ? aws_vpc. main [0 ] : data. awscc_ec2_vpc . main [0 ]
0 commit comments