Skip to content

kaihendry/trunk-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trunk based development with Terraform

Blog post

Requires Github enterprise or a public repo for the environments to work.

Idea is you setup a central bucket for tfstate, in this example hendry-bq-terraform.

You create workload identity and service accounts in oidc-setup/ and use those outputs to configure https://github.com/kaihendry/bq-terraform/settings/environments

You allow the service account write access to hendry-bq-terraform bucket to save default.tfstate in a prefix, e.g.

gsutil iam ch serviceAccount:github-action@stgtest-424513.iam.gserviceaccount.com:roles/storage.objectAdmin gs://hendry-bq-terraform
gsutil ls -r gs://hendry-bq-terraform
gs://hendry-bq-terraform/dev/:
gs://hendry-bq-terraform/dev/default.tfstate

gs://hendry-bq-terraform/stg/:
gs://hendry-bq-terraform/stg/default.tfstate

IAM permission troubleshooting

gcloud auth application-default revoke
gcloud auth application-default login

Developing locally

terraform init -backend-config="prefix=dev" -reconfigure -upgrade

Perhaps Terraform workspaces can be considered instead of prefixes.

About

Terraform version of Reusable Stacks (making envs as similar as possible)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published