Terraform support for GKE

Terraform is an Infrastructure as Code (IaC) tool that you can use to provision resources and permissions for multiple Google Cloud services, including Google Kubernetes Engine (GKE).

Terraform has a declarative and configuration-oriented syntax, which you can use to describe the infrastructure that you want to provision in your GKE project. After you author this configuration in one or more Terraform configuration files, you can use the Terraform CLI to apply this configuration to your GKE resources.

Using Terraform

Consider a scenario where you want to apply a standardized configuration to multiple GKE resources of a specific type. Using Terraform, you can streamline the entire process as follows:

  • Describe the infrastructure you want in a Terraform configuration file. You don't need to author code describing how to provision this configuration using objects and methods from the GKE API.
  • Use Terraform to evaluate your Terraform configuration and generate an execution plan. Based on this configuration, Terraform indicates what changes it plans to make to your GKE infrastructure.
  • Use Terraform to apply the changes in the execution plan. Terraform invokes the GKE API in the background to apply the planned changes.
    • If a GKE resource or infrastructure object defined in the Terraform configuration does not exist, Terraform creates it.
    • If a GKE resource or infrastructure object exists, but has a different configuration, Terraform updates it to match your Terraform configuration.
    • If any GKE resource or infrastructure object matches your Terraform configuration, Terraform leaves it unchanged.

To get started with Terraform for GKE, see Create a GKE cluster and deploy a workload using Terraform.

Terraform resources available for GKE

Terraform resources represent infrastructure objects. The following table lists some of the Terraform resources that are available for GKE:

GKE product or service Terraform resource
Google Kubernetes Engine (GKE) Standard edition google_container_cluster
Google Kubernetes Engine (GKE) Enterprise edition google_gke_hub_feature
Backup for GKE google_gke_backup_backup_plan

Learn more about Terraform

What's next