Spartan87
Spartan87

Reputation: 119

Connect to GKE cluster dynamically using terraform

I am using Terraform script to spin up a GKE cluster and then use helm 3 to install splunk connector on the cluster.

How do I connect to the newly created cluster in terraform kubernetes provider dynamically ?

Upvotes: 0

Views: 229

Answers (1)

Frederik Bode
Frederik Bode

Reputation: 2744

Let the provider depend on the cluster certificate:

data "google_client_config" "terraform_config" {
  provider = google
}

provider "kubernetes" {
  load_config_file = false
  host = "https://${google_container_cluster.my_cluster.endpoint}"
  cluster_ca_certificate = base64decode(google_container_cluster.my_cluster.master_auth[0].cluster_ca_certificate)
  token = data.google_client_config.terraform_config.access_token
}

Upvotes: 1

Related Questions