@@ -7,26 +7,22 @@ data "aws_availability_zones" "azs" {}
77
88// Only reference data sources which are gauranteed to exist at any time (above) in this locals{} block
99locals {
10- // Define canonical source of truth for this
11- external_vpc_mode = " ${ var . external_vpc_id != " " } "
12-
1310 // List of possible AZs for each type of subnet
1411 new_worker_subnet_azs = [" ${ coalescelist (keys (var. new_worker_subnet_configs ), data. aws_availability_zones . azs . names )} " ]
1512 new_master_subnet_azs = [" ${ coalescelist (keys (var. new_master_subnet_configs ), data. aws_availability_zones . azs . names )} " ]
1613
17- // How many AZs to create worker and master subnets in (always zero if external_vpc_mode)
18- new_worker_az_count = " ${ local . external_vpc_mode ? 0 : length (local. new_worker_subnet_azs )} "
19- new_master_az_count = " ${ local . external_vpc_mode ? 0 : length (local. new_master_subnet_azs )} "
14+ // How many AZs to create worker and master subnets in
15+ new_worker_az_count = " ${ length (local. new_worker_subnet_azs )} "
16+ new_master_az_count = " ${ length (local. new_master_subnet_azs )} "
2017
2118 // The base set of ids needs to build rest of vpc data sources
22- // This is crux of dealing with existing vpc / new vpc incongruity
23- vpc_id = " ${ local . external_vpc_mode ? var . external_vpc_id : element (concat (aws_vpc. new_vpc . * . id ,list (" " )),0 )} "
19+ vpc_id = " ${ aws_vpc . new_vpc . id } "
2420
2521 // When referencing the _ids arrays or data source arrays via count = , always use the *_count variable rather than taking the length of the list
2622 worker_subnet_ids = [" ${ coalescelist (aws_subnet. worker_subnet . * . id ,var. external_worker_subnet_ids )} " ]
2723 master_subnet_ids = [" ${ coalescelist (aws_subnet. master_subnet . * . id ,var. external_master_subnet_ids )} " ]
28- worker_subnet_count = " ${ local . external_vpc_mode ? length (var . external_worker_subnet_ids ) : local . new_worker_az_count } "
29- master_subnet_count = " ${ local . external_vpc_mode ? length (var . external_master_subnet_ids ) : local . new_master_az_count } "
24+ worker_subnet_count = " ${ local . new_worker_az_count } "
25+ master_subnet_count = " ${ local . new_master_az_count } "
3026}
3127
3228# all data sources should be input variable-agnostic and used as canonical source for querying "state of resources" and building outputs
0 commit comments