-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Cross Variable Validation When Using Nested Modules. #34117
Comments
Thanks for this feedback, @nuryupin-kr! One of your proposed solutions is to support conditions in modules. By that, did you mean conditions inside a I ask this because the rest of what you described made me assume you were talking about having the module check that its caller passed appropriate values, but adding conditions in a I think both are reasonable but I want to make sure we understand which of the two you want to have. |
Sorry for the confusion. Yes, something like this in the
OR having a
The option with |
Having cross variable validation enabled could be a solution as well :) |
An important detail about However, I'm still noticing that you are suggesting both checks in the caller and checks in the called module. Those feel like separate requirements to me: a module checking that the caller is passing suitable values is different to the caller checking that its own inputs to the module meet some condition that is presumably specific to that particular calling module. |
In that case if Looks like the only two options:
I could definitely find a scenario where it would be useful to have pre-conditions applied to the input data of a single child module. But more often than not we would want to apply validation globally. I guess the difference would be if validation is The other approach would be adding standalone I'm trying to be as specific as I can with wording so hopefully it all makes sense. :) |
While reading what you wrote I chuckled a bit because in my original proposal for what became Some subtext I'm reading into your answers is that you don't actually really care where the conditions live in your case, I assume because you're maintaining both the caller and the callee modules together and they are tightly coupled enough that the question of which module should be responsible for the checks is a totally irrelevant question. However, I think when we try to imagine a feature that would be useful for more than just your situation we do need to consider the situation where the calling module and the module being called are maintained separately by different teams, which raises two separate use-cases:
For me, this feels like two features that I think have both been requested previously and already have open issues:
I think both of those are reasonable, and if some or all of those changes would be acceptable for your situation then I'd suggest we close this issue and have you add a 👍 upvote to one or both of them to record your interest in it, which we'll then consider as part of deciding what to work on next. (Keeping this separate issue open would just "split the vote", making it harder to use the emoji reactions as a signal.) If you disagree with me that these are describing valid solutions to the problem you have then of course we can continue discussing to try to refine what makes this issue different from all of those. If the precondition part of option 2 seems like it would address your problem then I'd note that you can already write something that's functionally equivalent to that in today's Terraform, like this: resource "terraform_data" "checks" {
lifecycle {
precondition {
# (write in here whatever you would've written in the precondition
# block of the module, had that been allowed.)
}
}
}
module "example" {
# ...
depends_on = [terraform_data.checks]
} By declaring that Support for |
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. |
Terraform Version
Terraform v1.5.4 on windows_amd64 As of today, not aware of such feature being available in latest versions 1.6.x either.
Use Cases
When having terraform module that has one or more child(nested) modules, we would like to do a cross variable validation on a parent level, before passing data down to the child module. Validation should fail our configuration if the conditions aren't met.
As of today, we have the following features available:
None of these work for us.
Attempted Solutions
Proposal
Options:
check
block optionally fail so that way one can choose to have a warning or error.module
blocks.References
No response
The text was updated successfully, but these errors were encountered: