You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have use case in AWS lambda where we either want our user to provide the artifactory path for lambda code or his own code. There are 2 variables used as download artifactory needs local-exec mechanism where are local file needs archive zip way.
Right now, user can provide both options. We want options in variable to mar another variable as mutually exclusive
Attempted Solutions
N/A
Proposal
variable "local_file_content" { description = "If you have file present on owned tf, Mutually exclusive with download_location" type = "string" default = "" exclusive= ["download_location"] }
References
NA
The text was updated successfully, but these errors were encountered:
Thanks for this feature request, and sorry for the long delay in responding to it.
#34955 has recently been merged for inclusion in the forthcoming Terraform v1.9 release, and will allow input variable validation rules to refer to other symbols (including other input variables) declared in the same module.
That means it'll now be possible to write a validation rule that checks to ensure that at least one of two variables is null:
variable"a" {
type=stringdefault=null# Optional: if you also want to require that _at least one_ be set.validation {
condition=(var.a!=null|| var.b!=null)
error_message="Must set either 'a' or 'b'."
}
}
variable"b" {
type=stringdefault=nullvalidation {
condition=(var.a==null|| var.b==null)
error_message="Cannot set both 'a' and 'b'."
}
}
This does require making a seemingly-arbitrary decision about which of the two variables to hook the validation rule onto, which will then dictate which one Terraform indicates as being the problem in its error message. In this example I chose to report that at least one is required using a and that only one can be set using b, which is what I'd choose to do if I expected that a would be the more common choice than b, but of course this is a contrived example.
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.
Current Terraform Version
Use-cases
We have use case in AWS lambda where we either want our user to provide the artifactory path for lambda code or his own code. There are 2 variables used as download artifactory needs local-exec mechanism where are local file needs archive zip way.
Right now, user can provide both options. We want options in variable to mar another variable as mutually exclusive
Attempted Solutions
N/A
Proposal
variable "local_file_content" { description = "If you have file present on owned tf, Mutually exclusive with download_location" type = "string" default = "" exclusive= ["download_location"] }
References
NA
The text was updated successfully, but these errors were encountered: