github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/commands/graph.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Command: graph"
     4  sidebar_current: "docs-commands-graph"
     5  description: |-
     6    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.
     7  ---
     8  
     9  # Command: graph
    10  
    11  The `terraform graph` command is used to generate a visual
    12  representation of either a configuration or execution plan.
    13  The output is in the DOT format, which can be used by
    14  [GraphViz](http://www.graphviz.org) to generate charts.
    15  
    16  
    17  ## Usage
    18  
    19  Usage: `terraform graph [options] [DIR]`
    20  
    21  Outputs the visual dependency graph of Terraform resources according to
    22  configuration files in DIR (or the current directory if omitted).
    23  
    24  The graph is outputted in DOT format. The typical program that can
    25  read this format is GraphViz, but many web services are also available
    26  to read this format.
    27  
    28  The -type flag can be used to control the type of graph shown. Terraform
    29  creates different graphs for different operations. See the options below
    30  for the list of types supported. The default type is "plan" if a
    31  configuration is given, and "apply" if a plan file is passed as an
    32  argument.
    33  
    34  Options:
    35  
    36  * `-draw-cycles`    - Highlight any cycles in the graph with colored edges.
    37                        This helps when diagnosing cycle errors.
    38  
    39  * `-type=plan`      - Type of graph to output. Can be: `plan`, `plan-destroy`, `apply`,
    40                        `validate`, `input`, `refresh`.
    41  
    42  * `-module-depth=n` - (deprecated) In prior versions of Terraform, specified the
    43                        depth of modules to show in the output.
    44  
    45  ## Generating Images
    46  
    47  The output of `terraform graph` is in the DOT format, which can
    48  easily be converted to an image by making use of `dot` provided
    49  by GraphViz:
    50  
    51  ```shell
    52  $ terraform graph | dot -Tsvg > graph.svg
    53  ```
    54  
    55  Here is an example graph output:
    56  ![Graph Example](docs/graph-example.png)