It is clear enough based on Terraform documentation that you can have case statements for an attribute value. For example:
count = "${var.example == true ? 1 : 0}"
My question is, for the depends_on
parameter can you apply the same logic?
For example:
depends_on = [$var.example == true ?resource.name : another.resource.name}
Best Answer
Interpolation isn't supported inside
depends_on
at this time. For example if you tried to do this:You get an error:
The conditional you are using is a form of interpolation, therefore it's also invalid in this case.