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
I often use nested maps as variables and perform validation for complex situations. It would be great if i could provider extra context to the error_message a users sees by passing output from the condition check
Proposal
change condition to fail if non-true, meaning false or a string. the output of condition can be used as part of the error:
In the example below i want to make sure the keys listed in var.subnets contain only one key cidrs or netmask. private would error and be passed to error message:
validation {
error_message="Each subnet type must contain only 1 key: `cidrs` or `netmask`. Subnet type ${condition_output} violated."condition=[forsubnet_type, vinvar.subnets:subnet_typeiflength(setintersection(keys(v), ["cidrs", "netmask"])) !=1]
}
error proposal:
│ Error: Invalid value for variable
│
│ on variables.tf line 64:
│ 64: variable "subnets" {
│
│ Each subnet type must contain only 1 key: `cidrs` or `netmask`. Subnet type ["private"] violated.
References
The text was updated successfully, but these errors were encountered:
This seems very similar to the proposal made in #24160, which was recently closed via #30613. I'm not sure if making the condition value "truthy" wold be acceptable, but perhaps the ability to use expressions there would suffice for your needs?
Wow. What a coincidence. Yes i do think that provides a solution to my use case. It doesnt however help with DRYness. My suggestion for "truthy" is certainly more pythonic than gopher-ic 😅 Ill close this for now... I'm going to keep thinking on this to see if i can come up with another suggestion to help with DRY
Either way I'm really looking forward to when this new experiment is available
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
Your version of Terraform is out of date! The latest version
is 1.1.7. You can update by downloading from https://www.terraform.io/downloads.html```
Use-cases
I often use nested maps as variables and perform validation for complex situations. It would be great if i could provider extra context to the error_message a users sees by passing output from the condition check
Proposal
change
condition
to fail if non-true, meaningfalse
or a string. the output of condition can be used as part of the error:In the example below i want to make sure the keys listed in
var.subnets
contain only one keycidrs
ornetmask
. private would error and be passed to error message:validation propsal
error proposal:
References
The text was updated successfully, but these errors were encountered: