Skip to content

Commit bcc0960

Browse files
authored
Merge pull request terraform-google-modules#362 from terraform-google-modules/bugfix/zonal-region
Compute region output for zonal clusters
2 parents 9132bbe + e11a822 commit bcc0960

File tree

7 files changed

+35
-42
lines changed

7 files changed

+35
-42
lines changed

autogen/main.tf.tmpl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ locals {
9696
{% endif %}
9797

9898
cluster_output_name = google_container_cluster.primary.name
99-
cluster_output_location = google_container_cluster.primary.location
100-
cluster_output_region = google_container_cluster.primary.region
10199
cluster_output_regional_zones = google_container_cluster.primary.node_locations
102100
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
103101
cluster_output_zones = local.cluster_output_regional_zones
@@ -137,11 +135,12 @@ locals {
137135
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
138136
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
139137
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
140-
# cluster locals
138+
139+
cluster_location = google_container_cluster.primary.location
140+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
141+
cluster_zones = sort(local.cluster_output_zones)
142+
141143
cluster_name = local.cluster_output_name
142-
cluster_location = local.cluster_output_location
143-
cluster_region = local.cluster_output_region
144-
cluster_zones = sort(local.cluster_output_zones)
145144
cluster_endpoint = local.cluster_output_endpoint
146145
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
147146
cluster_master_version = local.cluster_output_master_version

main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ locals {
6464

6565

6666
cluster_output_name = google_container_cluster.primary.name
67-
cluster_output_location = google_container_cluster.primary.location
68-
cluster_output_region = google_container_cluster.primary.region
6967
cluster_output_regional_zones = google_container_cluster.primary.node_locations
7068
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
7169
cluster_output_zones = local.cluster_output_regional_zones
@@ -92,11 +90,12 @@ locals {
9290
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
9391
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
9492
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
95-
# cluster locals
93+
94+
cluster_location = google_container_cluster.primary.location
95+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
96+
cluster_zones = sort(local.cluster_output_zones)
97+
9698
cluster_name = local.cluster_output_name
97-
cluster_location = local.cluster_output_location
98-
cluster_region = local.cluster_output_region
99-
cluster_zones = sort(local.cluster_output_zones)
10099
cluster_endpoint = local.cluster_output_endpoint
101100
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
102101
cluster_master_version = local.cluster_output_master_version

modules/beta-private-cluster-update-variant/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ locals {
8888

8989

9090
cluster_output_name = google_container_cluster.primary.name
91-
cluster_output_location = google_container_cluster.primary.location
92-
cluster_output_region = google_container_cluster.primary.region
9391
cluster_output_regional_zones = google_container_cluster.primary.node_locations
9492
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
9593
cluster_output_zones = local.cluster_output_regional_zones
@@ -123,11 +121,12 @@ locals {
123121
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
124122
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
125123
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
126-
# cluster locals
124+
125+
cluster_location = google_container_cluster.primary.location
126+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
127+
cluster_zones = sort(local.cluster_output_zones)
128+
127129
cluster_name = local.cluster_output_name
128-
cluster_location = local.cluster_output_location
129-
cluster_region = local.cluster_output_region
130-
cluster_zones = sort(local.cluster_output_zones)
131130
cluster_endpoint = local.cluster_output_endpoint
132131
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
133132
cluster_master_version = local.cluster_output_master_version

modules/beta-private-cluster/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ locals {
8888

8989

9090
cluster_output_name = google_container_cluster.primary.name
91-
cluster_output_location = google_container_cluster.primary.location
92-
cluster_output_region = google_container_cluster.primary.region
9391
cluster_output_regional_zones = google_container_cluster.primary.node_locations
9492
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
9593
cluster_output_zones = local.cluster_output_regional_zones
@@ -123,11 +121,12 @@ locals {
123121
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
124122
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
125123
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
126-
# cluster locals
124+
125+
cluster_location = google_container_cluster.primary.location
126+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
127+
cluster_zones = sort(local.cluster_output_zones)
128+
127129
cluster_name = local.cluster_output_name
128-
cluster_location = local.cluster_output_location
129-
cluster_region = local.cluster_output_region
130-
cluster_zones = sort(local.cluster_output_zones)
131130
cluster_endpoint = local.cluster_output_endpoint
132131
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
133132
cluster_master_version = local.cluster_output_master_version

modules/beta-public-cluster/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ locals {
8888

8989

9090
cluster_output_name = google_container_cluster.primary.name
91-
cluster_output_location = google_container_cluster.primary.location
92-
cluster_output_region = google_container_cluster.primary.region
9391
cluster_output_regional_zones = google_container_cluster.primary.node_locations
9492
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
9593
cluster_output_zones = local.cluster_output_regional_zones
@@ -123,11 +121,12 @@ locals {
123121
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
124122
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
125123
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
126-
# cluster locals
124+
125+
cluster_location = google_container_cluster.primary.location
126+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
127+
cluster_zones = sort(local.cluster_output_zones)
128+
127129
cluster_name = local.cluster_output_name
128-
cluster_location = local.cluster_output_location
129-
cluster_region = local.cluster_output_region
130-
cluster_zones = sort(local.cluster_output_zones)
131130
cluster_endpoint = local.cluster_output_endpoint
132131
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
133132
cluster_master_version = local.cluster_output_master_version

modules/private-cluster-update-variant/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ locals {
6464

6565

6666
cluster_output_name = google_container_cluster.primary.name
67-
cluster_output_location = google_container_cluster.primary.location
68-
cluster_output_region = google_container_cluster.primary.region
6967
cluster_output_regional_zones = google_container_cluster.primary.node_locations
7068
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
7169
cluster_output_zones = local.cluster_output_regional_zones
@@ -92,11 +90,12 @@ locals {
9290
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
9391
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
9492
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
95-
# cluster locals
93+
94+
cluster_location = google_container_cluster.primary.location
95+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
96+
cluster_zones = sort(local.cluster_output_zones)
97+
9698
cluster_name = local.cluster_output_name
97-
cluster_location = local.cluster_output_location
98-
cluster_region = local.cluster_output_region
99-
cluster_zones = sort(local.cluster_output_zones)
10099
cluster_endpoint = local.cluster_output_endpoint
101100
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
102101
cluster_master_version = local.cluster_output_master_version

modules/private-cluster/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ locals {
6464

6565

6666
cluster_output_name = google_container_cluster.primary.name
67-
cluster_output_location = google_container_cluster.primary.location
68-
cluster_output_region = google_container_cluster.primary.region
6967
cluster_output_regional_zones = google_container_cluster.primary.node_locations
7068
cluster_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
7169
cluster_output_zones = local.cluster_output_regional_zones
@@ -92,11 +90,12 @@ locals {
9290
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
9391
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
9492
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]
95-
# cluster locals
93+
94+
cluster_location = google_container_cluster.primary.location
95+
cluster_region = var.regional ? google_container_cluster.primary.region : join("-", slice(split("-", local.cluster_location), 0, 2))
96+
cluster_zones = sort(local.cluster_output_zones)
97+
9698
cluster_name = local.cluster_output_name
97-
cluster_location = local.cluster_output_location
98-
cluster_region = local.cluster_output_region
99-
cluster_zones = sort(local.cluster_output_zones)
10099
cluster_endpoint = local.cluster_output_endpoint
101100
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
102101
cluster_master_version = local.cluster_output_master_version

0 commit comments

Comments
 (0)