@@ -3,11 +3,21 @@ locals {
33
44 # references to module.calculate_subnets output
55 calculated_subnets = module. calculate_subnets . subnets_by_type
6- subnet_keys = keys (var. subnets )
76
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 )
913 subnet_names = { for type , v in var . subnets : type => try (v. name_prefix , type) }
1014
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+
1121 singleton_subnet_types = [" public" , " transit_gateway" ]
1222 private_subnet_names = setsubtract (local. subnet_keys , local. singleton_subnet_types )
1323
@@ -21,7 +31,8 @@ locals {
2131 private_subnets_tgw_routed = [for type in local . private_subnet_names : type if can (var. subnets [type ]. route_to_transit_gateway )]
2232 private_subnet_key_names_tgw_routed = [for subnet in local . private_per_az : subnet if contains (local. private_subnets_tgw_routed , split (" /" , subnet)[0 ])]
2333
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
2536 # null = none
2637 # all = local.azs
2738 # single = local.azs[0]
@@ -34,6 +45,13 @@ locals {
3445 # options defined by `local.nat_options`
3546 nat_configuration = contains (local. subnet_keys , " public" ) ? local. nat_options [try (var. subnets . public . nat_gateway_configuration , " none" )] : local. nat_options [" none" ]
3647
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+
3755 # # if var.vpc_id is passed, assume create = `false` and cidr comes from data.aws_vpc
3856 create_vpc = var. vpc_id == null ? true : false
3957 vpc = local. create_vpc ? aws_vpc. main [0 ] : data. awscc_ec2_vpc . main [0 ]
0 commit comments