Reference environment variables in .tfvars file


I have a .tfvars file to supply a bunch of variables to Terraform. Now I also want to add a login secret, so I don’t want to hard-code it into the file but read it from an environment variable. Is it possible to do that in the file?

I am aware of the TF_VAR_ option, but I would like to define all variables in one place if possible.

Hi @Lutz,

It isn’t possible to define anything other than static values in a .tfvars file. The TF_VAR_... environment variable convention is the only way to pass variable values to Terraform via the process environment.

Alright, thanks for the quick reply!