devopsacademyau / 2020-jun-project1-externals

Creative Commons Attribution Share Alike 4.0 International
2 stars 2 forks source link

terraform.tfvars improvements #18

Closed roperto closed 4 years ago

roperto commented 4 years ago

TL;DR

  1. Add default values to variable.tf
  2. Delete terraform.tfvars (and commit deletion)
  3. Add /terraform/terraform.tfvars to .gitignore
  4. (optional) Create a terraform.example.tfvars

Explanation

The terraform.tfvars contains personal settings and should not be included in the repository.

For default values, we can use the default field when declaring the variable instead of putting them in terraform.tfvars

Next we add terraform.tfvars to gitignore (and delete the committed version) so we keep a clean status (git status should be clean most of the time) and avoid accidentally adding it back.

We can provide a terraform.example.tfvars which is a file that will not be loaded automatically and we put examples there. That is not so important as the variables file has nice descriptions, but can be added if you think its a nice touch.