Saturday, April 20, 2019

Terraform init in the real world

Rather than fully configuring your backend.tf in a file.
terraform {
 backend "gcs" {
   bucket  = "my-bucket-123"
  prefix  = "terraform/state" 
}
I prefer to use the command line in order avoid polluting the code with any environment specific names.

terraform init \    
           -backend-config="bucket=my-bucket-123" \     
           -backend-config="prefix=terraform/state
As Google Cloud Storage buckets are unique across all projects, they will change as you move from project to project.