Menu

1 / 2

Terraform tfvars and Safer Variable Values

DEV Community·Abraham Naiborhu·6 months ago
#i4vPYkb8
#terraform#googlecloud#enter#exit#article
Reading 0:00
15s threshold

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…

Continue reading — create a free account

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