One of the interesting features of Terraform is the ability to generate a dependency graph of the resource dependencies mentioned in the Terraform configuration.
In this recipe, we will see how to generate and visualize this dependency graph.
Getting ready
For this recipe, we need to use a third-party drawing generation tool called Graphviz, which is available for download at https://graphviz.gitlab.io/download/. You will need to download and install the package corresponding to your operating system.
Moreover, as an example, we will take the Terraform configuration available at https://github.com/PacktPublishing/Terraform-Cookbook/tree/master/CHAP04/sample-app.
How to do it…
To generate the graph dependencies, perform the following steps:
- Execute the terraform graph command:
terraform graph | dot -Tsvg > graph.svg
- Open the file explorer and navigate inside the folder that contains the Terraform configuration and open the file called graph...