File tree Expand file tree Collapse file tree 9 files changed +35
-36
lines changed Expand file tree Collapse file tree 9 files changed +35
-36
lines changed Original file line number Diff line number Diff line change @@ -107,9 +107,7 @@ resource "google_container_cluster" "primary" {
107107 node_config {
108108 service_account = " ${ lookup (var. node_pools [0 ], " service_account" , local. service_account )} "
109109 {% if beta_cluster % }
110- workload_metadata_config {
111- node_metadata = " ${ var . node_metadata } "
112- }
110+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
113111 {% endif % }
114112 }
115113 }
@@ -175,9 +173,7 @@ resource "google_container_node_pool" "pools" {
175173 }
176174 {% if beta_cluster % }
177175
178- workload_metadata_config {
179- node_metadata = " ${ var . node_metadata } "
180- }
176+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
181177 {% endif % }
182178 }
183179
Original file line number Diff line number Diff line change @@ -108,9 +108,7 @@ resource "google_container_cluster" "zonal_primary" {
108108 node_config {
109109 service_account = " ${ lookup (var. node_pools [0 ], " service_account" , local. service_account )} "
110110 {% if beta_cluster % }
111- workload_metadata_config {
112- node_metadata = " ${ var . node_metadata } "
113- }
111+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
114112 {% endif % }
115113 }
116114 }
@@ -176,9 +174,7 @@ resource "google_container_node_pool" "zonal_pools" {
176174 }
177175 {% if beta_cluster % }
178176
179- workload_metadata_config {
180- node_metadata = " ${ var . node_metadata } "
181- }
177+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
182178 {% endif % }
183179 }
184180
Original file line number Diff line number Diff line change @@ -52,7 +52,14 @@ locals {
5252 enabled = [{disabled = " false" }]
5353 disabled = []
5454 }
55+ {% if beta_cluster % }
56+
57+ cluster_node_metadata_config = {
58+ specified = [{node_metadata = " ${ var . node_metadata } " }]
59+ unspecified = []
60+ }
5561
62+ {% endif % }
5663 cluster_type_output_name = {
5764 regional = " ${ element (concat (google_container_cluster. primary . * . name , list (" " )), 0 )} "
5865 zonal = " ${ element (concat (google_container_cluster. zonal_primary . * . name , list (" " )), 0 )} "
Original file line number Diff line number Diff line change @@ -102,9 +102,7 @@ resource "google_container_cluster" "primary" {
102102
103103 node_config {
104104 service_account = " ${ lookup (var. node_pools [0 ], " service_account" , local. service_account )} "
105- workload_metadata_config {
106- node_metadata = " ${ var . node_metadata } "
107- }
105+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
108106 }
109107 }
110108
@@ -164,9 +162,7 @@ resource "google_container_node_pool" "pools" {
164162 count = " ${ lookup (var. node_pools [count . index ], " accelerator_count" , 0 )} "
165163 }
166164
167- workload_metadata_config {
168- node_metadata = " ${ var . node_metadata } "
169- }
165+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
170166 }
171167
172168 lifecycle {
Original file line number Diff line number Diff line change @@ -103,9 +103,7 @@ resource "google_container_cluster" "zonal_primary" {
103103
104104 node_config {
105105 service_account = " ${ lookup (var. node_pools [0 ], " service_account" , local. service_account )} "
106- workload_metadata_config {
107- node_metadata = " ${ var . node_metadata } "
108- }
106+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
109107 }
110108 }
111109
@@ -165,9 +163,7 @@ resource "google_container_node_pool" "zonal_pools" {
165163 count = " ${ lookup (var. node_pools [count . index ], " accelerator_count" , 0 )} "
166164 }
167165
168- workload_metadata_config {
169- node_metadata = " ${ var . node_metadata } "
170- }
166+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
171167 }
172168
173169 lifecycle {
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ locals {
5959 disabled = []
6060 }
6161
62+ cluster_node_metadata_config = {
63+ specified = [{
64+ node_metadata = " ${ var . node_metadata } "
65+ }]
66+
67+ unspecified = []
68+ }
69+
6270 cluster_type_output_name = {
6371 regional = " ${ element (concat (google_container_cluster. primary . * . name , list (" " )), 0 )} "
6472 zonal = " ${ element (concat (google_container_cluster. zonal_primary . * . name , list (" " )), 0 )} "
Original file line number Diff line number Diff line change @@ -102,9 +102,7 @@ resource "google_container_cluster" "primary" {
102102
103103 node_config {
104104 service_account = " ${ lookup (var. node_pools [0 ], " service_account" , local. service_account )} "
105- workload_metadata_config {
106- node_metadata = " ${ var . node_metadata } "
107- }
105+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
108106 }
109107 }
110108
@@ -158,9 +156,7 @@ resource "google_container_node_pool" "pools" {
158156 count = " ${ lookup (var. node_pools [count . index ], " accelerator_count" , 0 )} "
159157 }
160158
161- workload_metadata_config {
162- node_metadata = " ${ var . node_metadata } "
163- }
159+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
164160 }
165161
166162 lifecycle {
Original file line number Diff line number Diff line change @@ -103,9 +103,7 @@ resource "google_container_cluster" "zonal_primary" {
103103
104104 node_config {
105105 service_account = " ${ lookup (var. node_pools [0 ], " service_account" , local. service_account )} "
106- workload_metadata_config {
107- node_metadata = " ${ var . node_metadata } "
108- }
106+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
109107 }
110108 }
111109
@@ -159,9 +157,7 @@ resource "google_container_node_pool" "zonal_pools" {
159157 count = " ${ lookup (var. node_pools [count . index ], " accelerator_count" , 0 )} "
160158 }
161159
162- workload_metadata_config {
163- node_metadata = " ${ var . node_metadata } "
164- }
160+ workload_metadata_config = " ${ local . cluster_node_metadata_config [" ${ var . node_metadata == " UNSPECIFIED" ? " unspecified" : " specified" } " ]} "
165161 }
166162
167163 lifecycle {
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ locals {
5959 disabled = []
6060 }
6161
62+ cluster_node_metadata_config = {
63+ specified = [{
64+ node_metadata = " ${ var . node_metadata } "
65+ }]
66+
67+ unspecified = []
68+ }
69+
6270 cluster_type_output_name = {
6371 regional = " ${ element (concat (google_container_cluster. primary . * . name , list (" " )), 0 )} "
6472 zonal = " ${ element (concat (google_container_cluster. zonal_primary . * . name , list (" " )), 0 )} "
You can’t perform that action at this time.
0 commit comments