Menu

1 / 2

CI/CD for Terraform on GCP: Plan on Pull Request, Apply with Approval, No Static Keys

DEV Community·Abraham Naiborhu·6 months ago
#oYXCjbqg
#terraform#github#why#enter#exit
Reading 0:00
15s threshold

Hi guys, so, this will be my last lab.

In the previous labs, I used Terraform from my local machine.

The workflow was simple:

local terminal -> terraform plan -> terraform apply

Enter fullscreen mode

Exit fullscreen mode

That worked for learning, but it is not how I want to manage infrastructure changes in a more professional setup.

For this lab, I wanted to move Terraform execution into GitHub Actions.

The target workflow is:

Pull Request -> terraform fmt -> terraform validate -> terraform plan Manual Approval -> terraform apply

Enter fullscreen mode

Exit fullscreen mode

The main goal is not only automation.

The main goal is infrastructure change control.

In this lab, I built a Terraform CI/CD workflow using:

GitHub Actions

Google Cloud Workload Identity Federation

Terraform remote state in Google Cloud Storage

terraform fmt -check

terraform validate

terraform plan

manual terraform apply

no downloaded service account JSON key

The key idea is:

Terraform should not only create…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.