Creating GKE cluster and Ingress app with one apply


I am fairly new to Terraform and am attempting to set-up a GCP GKE cluster and then connect it to an Ingress application. I was able to successfully do so following this tutorial: Here is a link to the Github repo from the tutorial if you would like to see how the file is structured:

However, this method involves using Terraform to create the GKE cluster first then separately use the gcloud command line command to get the cluster credentials and then run several “kubectl apply” commands to create the Ingress application from a set of .yaml files. So basically, it becomes a two-step process of creating the GKE cluster and then separately creating an Ingress application.

My question is: is it possible to do both steps using only one “terraform apply” command? That is, have one Terraform file that both creates the GKE cluster and then also creates the Ingress application as well? Again, I am fairly new to Terraform, so if this is out of the scope of its capabilities, I understand! Any direction on where to move with this problem would be greatly appreciated!

Hi @paulwwstorm

Welcome to Terraform forums, it is a great technology for infrastructure.

Take a look at the following question about executing commands after infrastructure creation:

There is a Terraform provider for Kubernetes that you could use, but I would suggest that you write a different Terraform definition for that, as your GKE should have a longer and different life than the ingress app:

So actually not a single Terraform apply.

Thank you, Javier! I will look over the links you provided. Really appreciate the guidance.