In the previous lab, I configured Terraform remote state using Google Cloud Storage. I like that, but there was still one part of the workflow that i think can be automated.
Every time I ran:
terraform plan
Enter fullscreen mode
Exit fullscreen mode
or:
terraform apply
Enter fullscreen mode
Exit fullscreen mode
Terraform asked me to manually enter the Google Cloud project ID. I don't like that. So in this lab, I will improve the configuration by introducing:
terraform.tfvars
terraform.tfvars.example
safer GitHub patterns
variable validation
cleaner environment-based naming
The goal is not only to make Terraform stop asking for the project ID manually.
The goal is to make the configuration cleaner, safer, and closer to how Terraform is usually managed in a real project.
Reference: terraform website
Goals
The goals for this lab are simple:
Use terraform.tfvars to provide local variable values.
Stop typing the project ID manually during terraform plan and terraform apply .
Use…