terraform graph outputs a GraphViz DOT representation of Terraform’s configuration or infrastructure dependency graph. Inspecting that graph reveals resource dependencies, helps explain indirect effects, and can expose circular dependencies that are difficult to find otherwise. section 5.2.2 section 5.8
Use the command to:
- Inspect plan, plan-refresh-only, plan-destroy, or apply graphs with the -type flag. section 5.2.2
- Pipe DOT output through GraphViz’s dot tool to create viewable SVG or PNG diagrams. section 5.2.2
- Review dependencies when a resource change affects other resources that are not obviously connected. section 5.2.2
- Use a saved plan for apply graphs; without one, apply output can be empty because of a bug. section 5.2.2
Render a TLS module graph
From the directory containing the Terraform configuration, run `terraform graph | dot -Tpng > graph.png`. Terraform emits the dependency graph as DOT, and dot converts it into a PNG that is usually easier to interpret than CLI text. For a reusable DOT file, run `terraform graph > graph.dot`; for SVG, run `terraform graph | dot -Tsvg > graph.svg`. section 5.2.2
