LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

terraform-graph

Print a Terraform dependency graph in DOT format

TLDR

Print the resource dependency graph of the current configuration
$ terraform graph
copy
Render that graph to a PNG with Graphviz
$ terraform graph -type=plan | dot -Tpng > [graph.png]
copy
Graph the apply of a saved plan
$ terraform graph -plan=[path/to/tfplan]
copy
Highlight cycles in a plan graph
$ terraform graph -type=plan -draw-cycles
copy
Choose the operation the graph represents
$ terraform graph -type=[plan|plan-refresh-only|plan-destroy|apply]
copy

SYNOPSIS

terraform graph [options]

DESCRIPTION

terraform graph writes a dependency graph of the configuration, or of a selected operation, to standard output. The text is in the DOT language. The default graph shows only the order of resource and data blocks. -type selects a fuller graph for plan, plan-refresh-only, plan-destroy, or apply.The dot program from Graphviz turns that text into an image. Online DOT renderers accept the same text. The command does not change infrastructure or state.

PARAMETERS

-plan =tfplan

Graph the apply of a saved plan file. Implies -type=apply.
-draw-cycles
Color edges that form a cycle. Valid only together with -type.
-type =plan|plan-refresh-only|plan-destroy|apply
Draw the graph for that operation instead of the default resources-only graph. These graphs include more of the Terraform runtime and are harder to read.
-var 'name=value'
Set one input variable declared in the root module. Repeat the flag to set more than one.
-var-file filename
Load variable values from a .tfvars file. Repeat the flag to include more than one file.

INSTALL

sudo pacman -S terraform
copy
nix profile install nixpkgs#terraform
copy

CAVEATS

-draw-cycles is rejected unless -type selects an operation graph. The default simplified graph does not support it.-plan always implies -type=apply, even if another type is requested. The plan file has to be one terraform plan -out produced.The operation graphs expose implementation details of the Terraform runtime. They are diagnostic output, not a stable API.

HISTORY

Terraform was created by Mitchell Hashimoto at HashiCorp and first released in 2014.

SEE ALSO

RESOURCES

Copied to clipboard
Kai