Skip to content

pipetail/gke-terraform-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gke-terraform-demo

Terraform

To provision all the GCP resources we use terraform with terraform Google provider.

Remote backend (terraform state)

We use Google Cloud Storage buckets to store and version terraform state (*.tfstate) for each of the environments in their own GCP project.

bootstrapping

The bucket needs to be bootstrapped for each new environment by hand.

PROJECT_ID=$(gcloud config get-value project)
gsutil mb gs://${PROJECT_ID}-terraform-state

Enable versioning on the bucket to keep the history of your deployments.

gsutil versioning set on gs://${PROJECT_ID}-terraform-state

More details here.

In case of failure (e.g. pipeline agent hangs unexpectedly) you might need to run

terraform force-unlock <UUID>

to force-unlock the state.

Quickstart

gcloud auth login && gcloud auth application-default login

cd dev
terraform init
terraform apply

provider lock

terraform providers lock -platform=linux_arm64 -platform=linux_amd64 -platform=darwin_amd64 -platform=darwin_arm64 -platform=windows_amd64

About

terraform example for GKE + HTTPs LB + CloudSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages