Terraform
terraform graph command
The terraform graph command generates a visual representation of a configuration or execution plan that you can use to generate charts. This command uses the DOT language generate graphs. Refer to the GraphViz documentation for additional information.
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.-var 'NAME=VALUE'- Sets a value for a single input variable declared in the root module of the configuration. Use this option multiple times to set more than one variable. Refer to Input Variables on the Command Line for more information.-var-file=FILENAME- Sets values for potentially many input variables declared in the root module of the configuration, using definitions from a.tfvarsfile. Use this option multiple times to include values from more than one file. There are several other ways to set values for input variables in the root module, aside from the-varand-var-fileoptions. Refer to Assign values to input variables for more information.
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:
