-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Variable Namespace #1742
Comments
Thinking more about this, it might make more sense to just make a global variable scope option like such:
|
Hi @wazoo! This is a very interesting idea, but I think that ultimately it would be the wrong move for Terraform's modularity. We were intentional about our choice to force module inputs and outputs to be explicitly declared (via If it were possible to reference out to a global namespace on any line of config, it would mean the only way to be sure of a module's dependencies would be to read all its source code, which goes against the "black box of config" concept that modules were designed around. I'm happy to chat more with you on this thread about the problems you're trying to solve with this idea to see if there's another strategy we can bring to bear - but in the meantime I'm going to close the issue because I don't believe a global namespace is the direction we'll take. |
That is a great point. I actually thing with the introduction of templates this solves my problem as I was having to use modules as templates previously (to build a prod/stage environment) but I think I can refactor now using templates and it will be perfect. |
@phinze I would be very happy to have a conversation with you on this issue! The current variable scoping for terraform has been very painful for us. We have a large number of cross dependencies, and it's just killing us.... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Instead of passing variables in and out of modules it seems like it would be interesting if there was a global namespace, so I could do something like:
Then in the module something maybe like:
which might let me do this in another module:
This would save a lot of time and keep code modular, it would also make sure that you have some uniqueness globally. It also would be cool to be able to protect things from getting re-defined (or allow it), for example if I have a module that contains a firewall that re-defines the public subnet.
The text was updated successfully, but these errors were encountered: