1

Using Terraform v0.11.11, when invoking terraform plan, supply a .tfvars file that is NOT in the current directory e.g a common 'global' file for global constants

seems to just ignore it when I try ../ in an var-file option

-var-file="../$(ENV).global.tfvars"

What options do I have to achieve a similar result if this is not possible (event in the v0.12 is this still the case)?

user2992225
  • 247
  • 4
  • 14
  • what does your variables file look like - if the format is wrong TF will not pick it up: https://github.com/hashicorp/terraform/issues/12551 – victor m Feb 17 '19 at 17:40
  • Thanks for replying. Formats are fine since I copied the exact .tfvars files into the 'current' directory as well to test and it worked. When I tried to reference them with a relative path (e.g for parent dir -var-file="../xxxxx.tfvars) it didnt. So I assumed maybe relative paths dont work for -var-file? is this true / do you know of another way. Essentially Im trying to get around repetitively copying global var file around to each modules. Thanks! – user2992225 Feb 17 '19 at 19:07
  • 1
    If you are on linux you could use $(realpath ../$(ENV).global.tfvars) to return the absolute path of the file. try it out. – victor m Feb 18 '19 at 19:04
  • 1
    I used symlinks successfully for this scenario – Giulio Vian Feb 18 '19 at 21:03
  • awesome - realpath worked cheers! – user2992225 Feb 19 '19 at 10:29
  • or readlink: https://stackoverflow.com/a/284671/299421 – Federico Apr 17 '19 at 05:19

0 Answers0