Deployment of GCP resources through Terraform with GitHub Actions CI/CD Workflow

Cloud Journeys with Anindita
2 min readJul 18, 2022

The Google Cloud resources can be deployed through Terraform (IaC) with CI/CD pipeline to be maintained through GitHub Actions. In this blog post, we’ll explore how to deploy GKE cluster through Terraform with GitHub Actions CI/CD.

For deployment of GCP resources through GitHub Actions terraform workflow, you can use Terraform cloud as backend like as the following.

terraform {

cloud {

organization = “<your_terraform_cloud_org>”

workspaces {

name = “<workspace_name>”

}

}

}

Then, specify the .tfvars file variables in the terraform cloud variables section. You can declare the sensitive values for resource variables as applicable.

Terraform variables declared in TF cloud

Execute the terraform login command with your TF Cloud credentials. Create the TF_API_TOKEN values & paste it in GitHub repo Secrets section.

Utilize the following terraform workflow GitHub Actions workflow for GCP resource deployment. You can specify the Terraform workflow steps like terraform init, terraform format, terraform plan, terraform apply etc. Refer to the workflow .yml file for reference.

The GitHub Actions steps will look like as the following post completion.

You can also visualize the deployed GKE cluster & resources post the Actions workflow job completion.

GKE Cluster deployed through Terraform via GitHub Actions workflow CI/CD

--

--

Cloud Journeys with Anindita

Cloud Architect. Azure, AWS certified. Terraform & K8, Cloud Native expert. Passionate with GenAI. Views are own.