mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-14 22:02:22 -04:00
When you specify `-verbose` you'll get the whole graph of operations,
which gives a better idea of the operations terraform performs and in
what order.
The DOT graph is now generated with a small internal library instead of
simple string building. This allows us to ensure the graph generation is
as consistent as possible, among other benefits.
We set `newrank = true` in the graph, which I've found does just as good
a job organizing things visually as manually attempting to rank the nodes
based on depth.
This also fixes `-module-depth`, which was broken post-AST refector.
Modules are now expanded into subgraphs with labels and borders. We
have yet to regain the plan graphing functionality, so I removed that
from the docs for now.
Finally, if `-draw-cycles` is added, extra colored edges will be drawn
to indicate the path of any cycles detected in the graph.
A notable implementation change included here is that
{Reverse,}DepthFirstWalk has been made deterministic. (Before it was
dependent on `map` ordering.) This turned out to be unnecessary to gain
determinism in the final DOT-level implementation, but it seemed
a desirable enough of a property that I left it in.
55 lines
1.7 KiB
Markdown
55 lines
1.7 KiB
Markdown
---
|
|
layout: "docs"
|
|
page_title: "Command: graph"
|
|
sidebar_current: "docs-commands-graph"
|
|
description: |-
|
|
The `terraform graph` command is used to generate a visual representation of either a configuration or execution plan. The output is in the DOT format, which can be used by GraphViz to generate charts.
|
|
---
|
|
|
|
# Command: graph
|
|
|
|
The `terraform graph` command is used to generate a visual
|
|
representation of either a configuration or execution plan.
|
|
The output is in the DOT format, which can be used by
|
|
[GraphViz](http://www.graphviz.org) to generate charts.
|
|
|
|
|
|
## Usage
|
|
|
|
Usage: `terraform graph [options] [DIR]`
|
|
|
|
Outputs the visual dependency graph of Terraform resources according to
|
|
configuration files in DIR (or the current directory if omitted).
|
|
|
|
The graph is outputted in DOT format. The typical program that can
|
|
read this format is GraphViz, but many web services are also available
|
|
to read this format.
|
|
|
|
Options:
|
|
|
|
* `-draw-cycles` - Highlight any cycles in the graph with colored edges.
|
|
This helps when diagnosing cycle errors.
|
|
|
|
* `-module-depth=n` - The maximum depth to expand modules. By default this is
|
|
zero, which will not expand modules at all.
|
|
|
|
* `-verbose` - Generate a verbose, "worst-case" graph, with all nodes
|
|
for potential operations in place.
|
|
|
|
## Generating Images
|
|
|
|
The output of `terraform graph` is in the DOT format, which can
|
|
easily be converted to an image by making use of `dot` provided
|
|
by GraphViz:
|
|
|
|
```
|
|
$ terraform graph | dot -Tpng > graph.png
|
|
```
|
|
|
|
Alternatively, the web-based [GraphViz Workspace](http://graphviz-dev.appspot.com)
|
|
can be used to quickly render DOT file inputs as well.
|
|
|
|
Here is an example graph output:
|
|

|
|
|