A module that targets Terraform 1.15 declares these inputs:variable "min_size" {
type = number
}
variable "max_size" {
type = number
validation {
condition = var.max_size >= var.min_size
error_message = "max_size must be at least min_size."
}
}A caller sets min_size = 4 and max_size = 2. What happens when the caller runs terraform plan?
Choose one.
Input variable validation rules can reference other variables and objects in the same module (Terraform 1.9 and later).
The values are literals, so they are known before planning. Terraform 1.9 made validation conditions general expressions that may reference other input variables, so var.min_size is allowed and the comparison 2 >= 4 is false. Validation failure is an error that stops the run before a plan. The tempting distractor describes the pre-1.9 rule that a condition could reference only its own variable.
- Check the Terraform version: 1.15 is well past 1.9.
- Recall that validation may reference other variables since 1.9.
- Evaluate the condition with the caller's values: 2 >= 4 is false.
- Recall that a failed validation is an error raised before planning.
Exam tip: Since Terraform 1.9, a validation block can compare one input with another.
Terraform Professional (002): Turning Requirements into Predictable, Secure Configuration — the lesson that teaches this.