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}

Interpolation isn't supported inside depends_on at this time. For example if you tried to do this:

depends_on = ["${var.test}"]

You get an error:

depends on value cannot contain interpolations: ${var.test}

The conditional you are using is a form of interpolation, therefore it's also invalid in this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.