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 1414 * limitations under the License.
1515 */
1616
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+
1724data "google_container_cluster" "gke_cluster" {
1825 name = var. cluster_name
1926 location = var. location
@@ -26,9 +33,9 @@ data "template_file" "kubeconfig" {
2633 template = file (" ${ path . module } /templates/kubeconfig-template.yaml.tpl" )
2734
2835 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
3239 token = data.google_client_config.provider.access_token
3340 }
3441}
Original file line number Diff line number Diff line change @@ -27,12 +27,12 @@ output "kubeconfig_raw" {
2727output "cluster_ca_certificate" {
2828 sensitive = true
2929 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 )
3131}
3232
3333output "host" {
3434 description = " The host value for use with the kubernetes provider."
35- value = " https:// ${ data . google_container_cluster . gke_cluster . endpoint } "
35+ value = local . host
3636}
3737
3838output "token" {
You can’t perform that action at this time.
0 commit comments