Basically, where is the answer in SO how to do it in 0.13+ via
locals, but it does not include some important details:This check works only for known during
terraform plan values of variables.If value of any of variables in the check is not known during
terraform plan, the check will be skipped and error message will pop up only after terraform apply in the next terraform plan.The pic below is an example of how that check works.
Note, that there is a feature request to make able to refer to other variables in the variable condition check, but that's needs architecture redesign, so there no ETA when we can drop that hack.
P.S. You can achieve something similar by using lifecycle precondition and postcondition in case if you support only TF 1.2+
#terraform