Terraform provides a variable validation feature that allows defining conditions to validate variable inputs. Previously, variable validation only allowed validating the input of the variable itself. However, starting with Terraform 1.9, this feature has been enhanced to allow the addition of validation conditions that reference other input variables and objects. This blog presents a simple example that explains how to add a condition to one variable that references another variable.
Pre-requites: Terraform 1.9 or greater
The following sample script is used to create two Azure resource groups. One in the West Europe region and the other in the East US region. The two resource groups should not be created in the same region.