Have you ever wondered how Terraform Implicit Dependencies actually work in practice?
In today’s blog, I’m going to craft a toy example that demonstrates how I understand that they work using local_file
resources and thus not requiring any cloud connection or even internet connectivity.
What do you mean by Implicit Dependencies?
You might be wondering, “Implicit Dependencies… are those like the stuff artists do to avoid getting a Parental Advisory: Explicit Content sticker on their albums?” Which, yeah, I guess it could be but I’m talking about Terraform here. In Terraform, every time that you run a terraform plan
or terraform apply
, the tool is internally building a directed acyclic graph that models the dependencies between resources in your configuration that you specify using HCL. The edges in this graph are the dependency relationships between your resources and they are typically inferred by Terraform without you explicitly specifying them. It is possible to specify these dependencies explicitly using the depends_on meta-argument but, as I will discuss in this post, that won’t necessarily do what you might expect.