Terraform

Explain what depends_on used for and given an example

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

depends_on used to create an explicit dependency between resources in Terraform. For example, there is an application you would like to deploy in a cluster. If the cluster isn't ready (and also managed by Terraform of course) then you can't deploy the app. In this case, you will define "depends_on" in the app configuration and its value will be the cluster resource.