File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
+ locals {
18
+ cluster_ca_certificate = data. google_container_cluster . gke_cluster . master_auth != null ? data. google_container_cluster . gke_cluster . master_auth [0 ]. cluster_ca_certificate : " "
19
+ endpoint = data. google_container_cluster . gke_cluster . endpoint != null ? data. google_container_cluster . gke_cluster . endpoint : " "
20
+ host = data. google_container_cluster . gke_cluster . endpoint != null ? " https://${ data . google_container_cluster . gke_cluster . endpoint } " : " "
21
+ context = data. google_container_cluster . gke_cluster . name != null ? data. google_container_cluster . gke_cluster . name : " "
22
+ }
23
+
17
24
data "google_container_cluster" "gke_cluster" {
18
25
name = var. cluster_name
19
26
location = var. location
@@ -26,9 +33,9 @@ data "template_file" "kubeconfig" {
26
33
template = file (" ${ path . module } /templates/kubeconfig-template.yaml.tpl" )
27
34
28
35
vars = {
29
- context = data.google_container_cluster.gke_cluster.name
30
- cluster_ca_certificate = data.google_container_cluster.gke_cluster.master_auth[ 0 ] .cluster_ca_certificate
31
- endpoint = data.google_container_cluster.gke_cluster .endpoint
36
+ context = local.context
37
+ cluster_ca_certificate = local .cluster_ca_certificate
38
+ endpoint = local .endpoint
32
39
token = data.google_client_config.provider.access_token
33
40
}
34
41
}
Original file line number Diff line number Diff line change @@ -27,12 +27,12 @@ output "kubeconfig_raw" {
27
27
output "cluster_ca_certificate" {
28
28
sensitive = true
29
29
description = " The cluster_ca_certificate value for use with the kubernetes provider."
30
- value = base64decode (data . google_container_cluster . gke_cluster . master_auth [ 0 ] . cluster_ca_certificate )
30
+ value = base64decode (local . cluster_ca_certificate )
31
31
}
32
32
33
33
output "host" {
34
34
description = " The host value for use with the kubernetes provider."
35
- value = " https:// ${ data . google_container_cluster . gke_cluster . endpoint } "
35
+ value = local . host
36
36
}
37
37
38
38
output "token" {
You can’t perform that action at this time.
0 commit comments