# Basic usage - analyze current directory
terravision draw
# Specify source directory
terravision draw --source ~/projects/my-terraform-code
# Open diagram automatically after generation
terravision draw --source ~/projects/my-terraform-code --show
terravision drawGenerates architecture diagrams from Terraform code.
Syntax:
terravision draw [OPTIONS]
Common Options:
| Option | Description | Default | Example |
|---|---|---|---|
--source |
Source location (folder, Git URL, or JSON) | Current directory | ./terraform |
--format |
Output format (png, svg, pdf, bmp) | png |
--format svg |
--outfile |
Output filename | architecture |
--outfile my-diagram |
--workspace |
Terraform workspace | default |
--workspace production |
--varfile |
Variable file (can use multiple times) | None | --varfile prod.tfvars |
--show |
Open diagram after generation | False | --show |
--simplified |
Generate simplified high-level diagram | False | --simplified |
--annotate |
Path to annotations YAML file | None | --annotate custom.yml |
--aibackend |
AI backend (bedrock, ollama) | bedrock |
--aibackend ollama |
--planfile |
Pre-generated Terraform plan JSON | None | --planfile plan.json |
--graphfile |
Pre-generated Terraform graph DOT | None | --graphfile graph.dot |
--debug |
Enable debug output | False | --debug |
terravision graphdataExports resource relationships and metadata as JSON.
Syntax:
terravision graphdata [OPTIONS]
Common Options:
| Option | Description | Default | Example |
|---|---|---|---|
--source |
Source location | Current directory | ./terraform |
--outfile |
Output JSON filename | architecture.json |
--outfile resources.json |
--show_services |
Show only unique services list | False | --show_services |
--planfile |
Pre-generated Terraform plan JSON | None | --planfile plan.json |
--graphfile |
Pre-generated Terraform graph DOT | None | --graphfile graph.dot |
# Generate PNG diagram
terravision draw --source ./terraform
# Generate SVG diagram with custom name
terravision draw --source ./terraform --format svg --outfile my-architecture
# Use specific workspace
terravision draw --source ./terraform --workspace production
# Use variable files
terravision draw --source ./terraform --varfile prod.tfvars --varfile secrets.tfvars
# Analyze entire repository
terravision draw --source https://github.com/user/terraform-repo.git
# Analyze specific subfolder
terravision draw --source https://github.com/user/terraform-repo.git//aws/vpc
# Analyze specific branch
terravision draw --source https://github.com/user/terraform-repo.git?ref=develop
# Generate all formats
terravision draw --source ./terraform --format png --outfile arch-png
terravision draw --source ./terraform --format svg --outfile arch-svg
terravision draw --source ./terraform --format pdf --outfile arch-pdf
# Batch processing
for format in png svg pdf; do
terravision draw --source ./terraform --format $format --outfile arch-$format
done
# Use annotations file
terravision draw --source ./terraform --annotate custom-annotations.yml
# Annotations file will be auto-loaded if named terravision.yml in source directory
terravision draw --source ./terraform
See ANNOTATIONS.md for annotation file format.
# Export graph data
terravision graphdata --source ./terraform --outfile graph.json
# Generate diagram from exported data (faster)
terravision draw --source graph.json --format svg
# Show only services used
terravision graphdata --source ./terraform --show_services
# Enable debug output
terravision draw --source ./terraform --debug
# This creates tfdata.json which can be reused
terravision draw --source tfdata.json --format svg
TerraVision supports all output formats provided by Graphviz. Use the --format option to specify your desired format.
| Format | Description | Best For |
|---|---|---|
png |
Portable Network Graphics (default) | Documentation, wikis, presentations |
svg |
Scalable Vector Graphics | Web pages, scalable diagrams, editing |
pdf |
Portable Document Format | Reports, printing, professional docs |
jpg / jpeg |
JPEG image | Photos, web (lossy compression) |
gif |
Graphics Interchange Format | Simple graphics, animations |
bmp |
Windows Bitmap | Windows applications |
eps |
Encapsulated PostScript | Print publishing, LaTeX |
ps / ps2 |
PostScript | Print publishing |
tif / tiff |
Tagged Image File Format | High-quality archival |
webp |
WebP format | Modern web (good compression) |
dot |
Graphviz DOT source | Further editing, custom rendering |
json |
Graphviz JSON with layout info | Advanced programmatic processing (note: different from graphdata output) |
xdot |
Extended DOT with layout | Advanced rendering applications |
For the complete list of supported formats, see the Graphviz Output Formats documentation.
Note: --format json produces Graphviz’s internal JSON format with layout coordinates. For TerraVision’s simple graph dictionary (just nodes and connections), use the graphdata command instead.
terravision draw --source ./terraform --format png
terravision draw --source ./terraform --format svg
terravision draw --source ./terraform --format pdf
If you already have Terraform plan and graph output files (e.g. from a CI/CD pipeline), you can generate diagrams without running Terraform. This is useful when:
Step 1: Generate plan and graph files (in your Terraform environment):
cd /path/to/terraform
terraform init
terraform plan -out=tfplan.bin
terraform show -json tfplan.bin > plan.json
terraform graph > graph.dot
Step 2: Generate diagrams (no Terraform or cloud credentials needed):
# Draw diagram from pre-generated files
terravision draw --planfile plan.json --graphfile graph.dot --source ./terraform
# Export graph data from pre-generated files
terravision graphdata --planfile plan.json --graphfile graph.dot --source ./terraform --outfile resources.json
# Combine with other options
terravision draw --planfile plan.json --graphfile graph.dot --source ./terraform \
--format svg --outfile my-architecture --annotate custom.yml
Requirements:
--planfile must be a JSON file from terraform show -json (not a binary .tfplan file)--graphfile must be a DOT file from terraform graph--source must point to the Terraform source directory (for HCL parsing)--planfile, --graphfile, --source) are required togetherNotes:
--workspace and --varfile are ignored when --planfile is used (a warning is printed)--planfile moderesource_changes with at least one resourceSee CI/CD Integration for pipeline examples using pre-generated plan files.
# Generate diagrams for different environments
terravision draw --source ./terraform --varfile dev.tfvars --outfile arch-dev
terravision draw --source ./terraform --varfile staging.tfvars --outfile arch-staging
terravision draw --source ./terraform --varfile prod.tfvars --outfile arch-prod
For large infrastructures, generate high-level overview:
terravision draw --source ./terraform --simplified --outfile overview
# Use AWS Bedrock (default)
terravision draw --source ./terraform --aibackend bedrock
# Use local Ollama
terravision draw --source ./terraform --aibackend ollama
See AI_REFINEMENT.md for setup instructions.
terravision draw --source ./terraform --simplified
terravision graphdata --source ./terraform --outfile graph.json
terravision draw --source graph.json --format png
terravision draw --source graph.json --format svg
terravision draw --source ./terraform --workspace production
# Process multiple Terraform directories
for dir in terraform/*; do
terravision draw --source $dir --outfile $(basename $dir)
done
# Quick check of current infrastructure
terravision draw --show
# Generate diagram for PR review
terravision draw --source ./terraform --format svg --outfile pr-${PR_NUMBER}
# Generate all formats for documentation
terravision draw --format png --outfile docs/images/architecture
terravision draw --format svg --outfile docs/images/architecture
# Generate diagram with build number
terravision draw --format svg --outfile architecture-${BUILD_NUMBER}
See CICD_INTEGRATION.md for complete CI/CD examples.