-
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
central place to define module versions #31701
Comments
I have the same need to be able to parameterize the versions of the modules between environments and also, it could apply for the complete I am following other associated issues but at the moment, there is no native Terraform functionality that allows it. Thank you for creating the issue and giving visibility to this problem. |
Thanks for the feature request. I see the problem here and there are several ways we could solve it. |
Indeed thanks for starting this discussion! This reminds me of a similar situation that historically existed for providers, where we had overloaded the
We resolved that ambiguity/conflict in Terraform v0.13 by introducing the dependency lock file as a new place to capture the second piece of information, and thereby left the module itself to only worry about the first piece of information. The situation isn't quite the same for modules as it is for providers, because Terraform allows each individual However, it does seem like the similar overloading/ambiguity is getting in the way here: you are trying (reasonably) to use the module If there were hypothetically also a lock-file-like mechanism for module calls then the We already have #31301 open to represent the idea of tracking module version selections in the lock file, and so if that is the direction we end up taking here then this issue might end up considered a duplicate of that one. However, that doesn't feel like it's a clear decision to me yet, so I'm just going to create the link between the two issues for now and then we can revisit later on whether it makes sense to consolidate these together into a single request. |
In my personal blog (so: not official HashiCorp statements) I recently wrote an article about why I don't think Terraform should support fully-dynamic module source addresses, which is not directly related to what this issue is discussing but does overlap with an alternative idea I discussed in there: allowing to override the installation location for a module registry or provider registry source address in a "dependency override file". The overall concept is that our registry-style source addresses already serve as an abstraction that separates the physical source location from the name used to talk about the dependency, but today that mapping between logical address and physical address is (for modules) controlled exclusively by the origin module registry. I've proposed to allow the user to override that mapping locally. However, that idea does still assume that That would then, along with serving other use-cases, allow a solution to the specific use-case in this issue: an author could choose to leave the version constraint in a |
Terraform Version
Terraform v1.2.3 on darwin_amd64 + provider registry.terraform.io/hashicorp/aws v4.12.1 + provider registry.terraform.io/hashicorp/random v3.3.2 Your version of Terraform is out of date! The latest version is 1.2.8. You can update by downloading from https://www.terraform.io/downloads.html
Use Cases
in large terraform files its annoying to have to search replace module versions and source (if switching from local to remote during development). This is especially worse if you are including the same module multiple times
Attempted Solutions
it's possible to do something to help with multi calls to the same module by creating a wrapper
/main.tf
/wrappers/a/main.tf
Then you only have to update the relatively small files inside /wrappers/*/main.tf but this is annoying as you have to duplicate in the variables inside the wrapper module and pass them through and potential outputs
Proposal
Provide a central place to define module version and source then inside tf files refer to this external constant so that a single location can be defined making version bumping easy and less error prone
Something if like below would seem the terraformy way
packages.tf
main.tf
References
The text was updated successfully, but these errors were encountered: