Search code examples
terraform

How to define global variables in terraform?


I have a terraform project I am working on. In it, I want a file to contain many variables. I want these variables to be accessible from any module of the project. I have looked in the docs and on a Udemy course but still don't see how to do this. How does one do this in terraform?


Solution

  • I don't think this is possible. There are several discussions about this at Github, but this is not something the Hashicorp team wants.

    In general we're against the particular solution of Global Variables, since it makes the input -> resources -> output flow of Modules less explicit, and explicitness is a core design goal.

    I know, we have to repeat a lot of variables between different modules