Skip to content

re: Terraform: use a variable's value to define another variable VIEW POST


The reason this works is due to Terraform variable values (and providers) do not support interpolation. The TF engine is not yet running when the values are assigned.

outputs on the other hand are evaluated near the end of a TF life cycle. Thus the engine is running and interpolation is supported.

Another way to to this is use a null object and apply the value = "${var.nickname != "" ? var.nickname : var.fullname}" logic to it.

Side note; might want to check out upgrading the TF 0.12.x when you get a chance. The resource/var/output sytax changes a bit.

code of conduct - report abuse