Explicit Resource Dependencies
Learn to manage explicit resource dependencies in Terraform.
We'll cover the following
Explicit dependency
We created a resource that Terraform knew was dependent on another (the VPC subnet) in implicit dependencies. It was dependent because the logic within the provider
code knows that.
But what about dependencies that are not part of the structure of resources themselves but part of the logic of our application?
For example, we might have a dependency in our application between an EC2 virtual machine on AWS and a load balancer on Azure. This would not be captured automatically by Terraform, but fortunately, we can specify it.
We’ll use this scenario to figure out what’s different this time. First, we need to create and initialize a new directory: ltthw_dependencies
.
Note: For environment variables, we use
TF_VAR_region
,TF_VAR_YOURSECRETKEY
andTF_VAR_YOURACCESSKEY
independencies.tf
.
Get hands-on with 1400+ tech skills courses.