Skip to content

Terraform Graph

Step-01: Introduction

  • 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.

Step-02: Run Terraform Graph command

# Terraform Initialize
terraform init

# Terraform Graph
terraform graph > dot1
Observation: 
This command will output DOT format text and store in file dot1

Step-03: Online Graphviz Viewers

  • Graphviz-Online
  • Edotor-Online
  • Copy and paste the text from dot1 file generated in step-02 in these online Graphviz Viewers
  • Review the output

Step-04: Clean-Up

# Delete .terraform files
rm -rf .terraform*

Step-05: Other Options - Offline Graphviz Installer

Step-05-01: Pre-requisite notes

  • Graphviz is unstable on MacOS
  • Graphviz needs xcode to be installed on MacOS which consumes huge disk space.
  • With that said, we are going to do this demo on Windows Machine
  • We are going to use Windows 2019 EC2 instance created on AWS for the same.

Step-05-02: Create Windows 2019 VM ready

  • Create Windows 2019 VM on AWS Cloud
  • Disable Browser security settings in Server-Manager
  • Install Google Chrome
  • Download & Install Terraform CLI
  • Set Path for Terraform CLI
  • Copy terraform-manifests folder from section-14: Terraform Graph of the course to Windows VM

Step-05-03: Install Graphviz on Windows VM

  • Download Graphviz
  • Install Graphviz
    # Switch Directory
    cd c:\graphviz-demo\terraform-manifests
    
    # Terraform Initialize
    terraform init
    
    # Terraform Graph
    terraform graph > dot1
    Observation: 
    This command will output DOT format text
    
    # Terraform Graph in Image format
    terraform graph | dot -Tsvg > graph.svg
    
    # Verify
    open graph.svg in browser
    

References

🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99 $84.99 81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer