Terraform
Command: graph
The terraform graph
command produces descriptions of the relationships
between objects in a Terraform configuration, using
the DOT 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
, orapply
.
Generating Images
The graph output uses
the DOT language,
which is a machine-readable graph description language which originated in
Graphviz. 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:
$ terraform graph -type=plan | dot -Tpng >graph.png
The following is an example result: