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
variable"my_variable_name" {
type=object({
a =string
b =string
})
validation {
condition=var.my_variable_name==null|| (var.my_variable_name.a!=null&& var.my_variable_name.b!=null)
error_message="Something."
}
}
Debug Output
Error: Attempt to get attribute from null value
on [...]/variables.tf line 96, in variable "my_variable_name":
96: condition = var.my_variable_name == null || (var.my_variable_name.a != null && var.my_variable_name.b != null)
|----------------
| var.my_variable_name is null
This value is null, so it does not have any attributes.
on [...]/variables.tf line 96, in variable "my_variable_name":
96: condition = var.my_variable_name == null || (var.my_variable_name.a != null && var.my_variable_name.b != null)
|----------------
| var.my_variable_name is null
This value is null, so it does not have any attributes.
Expected Behavior
if var.my_variable_name is null, the condition for variable-validation should evaluate to true
Actual Behavior
error returned because the right part of the validation expression is evaluated. It fails evaluating both var.my_variable_name.a and var.my_variable_name.b because var.my_variable_name is null
The text was updated successfully, but these errors were encountered:
Thanks for filing the issue. This isn't specific to variable validation, conditional operators not short-circuiting evaluation is a known issue we're tracking in #24128.
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.
ghost
locked as resolved and limited conversation to collaborators
May 1, 2021
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
custom-conditionsFeedback on variable validation, preconditions. postconditions, checks, and test assertions
Terraform Version
0.12.24
Terraform Configuration Files
Debug Output
Expected Behavior
if
var.my_variable_name
is null, the condition for variable-validation should evaluate to trueActual Behavior
error returned because the right part of the validation expression is evaluated. It fails evaluating both
var.my_variable_name.a
andvar.my_variable_name.b
becausevar.my_variable_name
is nullThe text was updated successfully, but these errors were encountered: