Create resources using multiple Terraform providers (GCP and Kubernetes) in the same TF script

263 Views Asked by At

I'm new to Terraform.

I am trying to:

  1. Create a Kubernetes cluster in GCP (GKE) using Terraform
  2. Deploy a K8s deployment to the same cluster using Terraform

How can I process to create a new cluster on GCP, and deploy some service on the cluster just created?

1

There are 1 best solutions below

1
On

You should use first provider with host, token and ca_certificate.

The one with config_path will use config from your host, so will try to run kubernetes provider using your user, not terraform service account.

Provider configuration looks good, I use same and it works.

Do you set up single cluster using Terraform or many? Can you share your terraform resources?