Interview Prep/Terraform/Variables, Locals, Outputs and Types

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.

All Terraform questions Roadmap: Terraform

More on Variables, Locals, Outputs and Types