-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Enforce the provider version within the module #20996
Comments
Hi @chenrui333 ! I'm sorry, but I'm not quite following your question. Can you explain a bit more about what you are trying to achieve? Are you trying to override the provider version set in the module? If the provider version is set in the module itself, terraform will use that version. There can only be one version of any given provider, so you don't need to "repeat" the provider version. If you have a module that is not setting the provider version, you can always set the provider version at the top-level |
@mildwonkey That sounds pretty cool, where can I see the example? |
Sure, here's a (made-up) example. If you have this module "foo" {
source = "./bar"
} And this module in provider "random" {
version = ">= 2.0.0"
}
resource "random_string" "example" {
[ ... ]
} Terraform will use the random provider >= v2.0. Alternatively, if the module does not have a provider version specified, you can get the same behavior by putting the provider version in provider "random" {
version = ">= 2.0.0"
}
module "foo" {
source = "./bar"
} Keep in mind that this would cause an error, because the provider versions specified cannot be reconciled:
provider "random" {
version = "1.0.0"
}
module "foo" {
source = "./bar"
}
provider "random" {
version = ">= 2.0.0"
}
resource "random_string" "example" {
[ ... ]
} Does this help? |
@mildwonkey yeah, that is certainly help, I have to play around to see how the error message looks like. Also, I have found this issue, #16835, sounds like very much the same idea does get implemented in the tf 0.12 version. :) |
Works pretty good for me, thanks @mildwonkey ! |
@mildwonkey. not sure if it is relevant, I do encounter a issue to pass the version as variable to the provider block within the module: ./bar/main.tf:
When I do terraform plan, it complains about missing the provider region declaration. |
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. |
Recently, I have run into a issue that the module is using the latest available provider feature (PR details).
I wonder if I can enforce the provider version within the module, something like:
In other words, the peerDependency between the modules.
The text was updated successfully, but these errors were encountered: