mirror of
https://github.com/hashicorp/terraform.git
synced 2026-04-29 01:59:00 -04:00
Unless a user specifically requests a real operation graph using the -type option, we'll by default present a simplified graph which only represents the relationships between resources, since resources are the main side-effects and so the ordering of these is more interesting than the ordering of Terraform's internal implementation details.
56 lines
2.1 KiB
Text
56 lines
2.1 KiB
Text
---
|
|
page_title: 'Command: graph'
|
|
description: >-
|
|
The terraform graph command generates a visual representation of a
|
|
configuration or execution plan that you can use to generate charts.
|
|
---
|
|
|
|
# Command: graph
|
|
|
|
The `terraform graph` command produces descriptions of the relationships
|
|
between objects in a Terraform configuration, using
|
|
[the DOT language](https://en.wikipedia.org/wiki/DOT_(graph_description_language)).
|
|
|
|
## Usage
|
|
|
|
Usage: `terraform graph [options]`
|
|
|
|
By default the result is a simplified graph which describes only the dependency
|
|
ordering of the resources (`resource` and `data` blocks) in the configuration.
|
|
|
|
The `-type=...` option optionally selects from a number of other graph types
|
|
which have more detail, at the expense of also exposing some of the
|
|
implementation details of the Terraform language runtime.
|
|
|
|
Options:
|
|
|
|
* `-plan=tfplan` - Produce a graph for applying the given plan. Implies `-type=apply`.
|
|
|
|
* `-draw-cycles` - Highlight any cycles in the graph with colored edges.
|
|
This helps when diagnosing cycle errors. This option is supported only when
|
|
selecting one of the real graph operaton types using the `-type=...`
|
|
option.
|
|
|
|
* `-type=...` - Selects a specific operation type to show the graph of, instead
|
|
of the default resources-only simplified graph.
|
|
Can be: `plan`, `plan-refresh-only`, `plan-destroy`, or `apply`.
|
|
|
|
## Generating Images
|
|
|
|
The graph output uses
|
|
[the DOT language](https://en.wikipedia.org/wiki/DOT_(graph_description_language)),
|
|
which is a machine-readable graph description language which originated in
|
|
[Graphviz](https://graphviz.org/). You can use the Graphviz `dot` command
|
|
to present the resulting graph description as an image. There are also various
|
|
third-party online graph rendering services which accept this format.
|
|
|
|
If you have the Graphviz `dot` command already installed, you can render
|
|
a PNG image by piping into that command:
|
|
|
|
```shellsession
|
|
$ terraform graph -type=plan | dot -Tpng >graph.png
|
|
```
|
|
|
|
The following is an example result:
|
|
|
|

|