Search⌘ K
AI Features

Implicit Resource Dependencies

Explore how Terraform handles implicit resource dependencies and the use of the -target flag to plan and selectively destroy resources. Understand Terraform's dependency graph and how it automates infrastructure provisioning regardless of resource declaration order.

Dependencies

The dependencies are the bane of any infrastructure manager’s life. If we switch off the Virtual Machine (VM), who will complain? What about the load balancer?

Stories of switching off servers to see who complains as a way of managing unknown dependencies are incredibly common in the IT industry.

Terraform can help manage that problem by codifying and tracking resource dependencies. However, it’s important to remember that it does not do so by magic and that our application dependencies may still need to be mapped out by whoever’s in charge of them.

Implicit dependency

Initially, we need to set up our credentials. Then, we create a new directory with a Terraform module.

We also create a Terraform module with a defined AWS provider.

Then we add two resources to the dependencies.tf file. The first is ...