Can a variable validation reference other variables?
AdvancedConceptVariables, Locals, Outputs and Types
Answer
Since Terraform 1.9 yes: condition and error_message can reference other variables, locals, data sources and resources, not only the variable being validated. Before 1.9 each validation could only reference its own variable, so cross-field rules needed precondition blocks on a resource or output. Check required_version before relying on it.
More on Variables, Locals, Outputs and Types
How do you declare an input variable?BeginnerIn what order does Terraform load variable values?BeginnerHow do you define an output and what is it for?BeginnerWhat is the difference between locals and variables?BeginnerWhat are the primitive types in Terraform?BeginnerHow do list, set and map differ?Intermediate