AI-Powered Terraform to Architecture Diagram Generator
β οΈ Alpha Software Notice
This software is in alpha testing. Code is shared "AS IS" without warranties. Use at your own risk.
- What is TerraVision?
- Quick Start
- Key Features
- Installation
- Basic Usage
- Documentation
- Supported Cloud Providers
- Contributing
- License
TerraVision automatically converts your Terraform code into professional cloud architecture diagrams. Quickly visualise any Terraform code to analyse what would be created in the cloud, AND keep your documentation in sync with your infrastructure. No more outdated diagrams!
Turn this Terraform code:
Into these architecture diagrams:
- β Always Up-to-Date: Diagrams generated from actual Terraform code as the single source of truth
- β 100% Client-Side: No cloud access required, runs locally to keep your data secure
- β CI/CD Ready: Automate diagram generation in a pipeline whenever a PR is merged
- β Free & Open Source: No expensive diagramming tool licenses
- β Multi-Cloud: Supports AWS, GCP, and Azure
- Industry-standard cloud provider icons (AWS, GCP, Azure)
- Automatic resource grouping (VPCs, subnets, security groups)
- Clean, readable layouts
- Multiple output formats (PNG, SVG, PDF and DOT)
- Automatically fixes resource relationships
- Adds missing logical connections, labels, titles and icons as needed
- Ensures architectural diagramming best practices
- Add custom labels and titles
- Include external resources not in Terraform
- Override automatic connections
- GitHub Actions, GitLab CI, Jenkins support
- Show multiple environments using TF Variables to document variants of your infrastructure (e.g. prod vs dev)
- No cloud credentials required
- Runs entirely on your local machine
- No external API calls (except optional AI features)
You can run terravision from within a Docker container. Pull the pre-built image from Docker Hub:
docker pull patrickchugh/terravision:latestOr build it yourself from source:
git clone https://github.com/patrickchugh/terravision.git && cd terravision
docker build -t patrickchugh/terravision .Then use it with any of your terraform files by mounting your local directory to the container:
If you pulled from Docker Hub, use patrickchugh/terravision as the image name. If you built locally, use terravision (or whatever tag you chose).
# Using Docker Hub image
$ docker run --rm -it -v $(pwd):/project patrickchugh/terravision draw --source /yourproject/ --varfile /project/your.tfvars
$ docker run --rm -it -v $(pwd):/project patrickchugh/terravision draw --source https://github.com/your-repo/terraform-examples.git//mysubfolder/secondfolder/
# Using self-built image
$ docker run --rm -it -v $(pwd):/project terravision draw --source /yourproject/ --varfile /project/your.tfvars
$ docker run --rm -it -v $(pwd):/project terravision draw --source https://github.com/your-repo/terraform-examples.git//mysubfolder/secondfolder/Depending on your cloud provider, you may need to pass your credentials so that OpenTofu/Terraform can run terraform plan commands
For example, for AWS:
# Example 1 Mount AWS Credentials folder
docker run -it --rm -v $(pwd):/project -v ~/.aws:/home/terravision/.aws:ro patrickchugh/terravision draw --source /path/to/terraform_source
# Example 2 Pass credentials as environment variables
docker run -it --rm -v $(pwd):/project -e AWS_ACCESS_KEY_ID=your-access-key -e AWS_SECRET_ACCESS_KEY=your-secret-key patrickchugh/terravision draw --source /path/to/terraform_sourceBefore installing TerraVision, ensure you have:
- Python 3.10+ - Download Python
- Terraform 1.x - Install Terraform
- Graphviz - Install Graphviz
- Git - Install Git
- Ollama (Optional - for local AI refinement) - Install Ollama
pipx install terravision # only if in a virtual env, you can use pip install terravision insteadBefore generating diagrams, ensure Terraform is working:
# Verify Terraform is installed
terraform version
# Should show v1.0.0 or higher
# Configure cloud provider credentials
# AWS:
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
# Or: aws configure
# Azure:
export ARM_CLIENT_ID="your-client-id"
export ARM_CLIENT_SECRET="your-client-secret"
export ARM_TENANT_ID="your-tenant-id"
export ARM_SUBSCRIPTION_ID="your-subscription-id"
# Or: az login
# GCP:
export GOOGLE_CREDENTIALS="path/to/service-account-key.json"
# Or: gcloud auth application-default login
# Test Terraform can initialize and plan
cd tests/fixtures/aws_terraform/static-website # or azure_terraform/test_vm_vmss
terraform init
terraform plan
# Should complete without errors
cd -Note: TerraVision needs Terraform to successfully run terraform plan to parse your infrastructure. Cloud credentials are required for TERRAFORM to validate resources and resolve functions, but TerraVision itself never accesses your cloud account.
Important for Terraform Enterprise and Remote Backend Users: TerraVision automatically forces local backend execution (ignoring remote state) to generate diagrams showing the complete infrastructure definition, not just deltas. This ensures accurate architecture visualization regardless of your configured backend.
If you have Nix installed with flakes enabled, you can enter a development shell with terravision and all dependencies available:
git clone https://github.com/patrickchugh/terravision.git && cd terravision
nix developThis provides terravision, graphviz, terraform, and git in your shell. You can also run it directly without cloning:
nix run github:patrickchugh/terravision -- draw --source /path/to/terraform --showGenerate your first diagram using our example Terraform code:
git clone https://github.com/patrickchugh/terravision.git
cd terravision
# Example 1: EKS cluster with fully managed nodes (auto)
terravision draw --source tests/fixtures/aws_terraform/eks_automode --show
# Example 2: Azure VM stack set
terravision draw --source tests/fixtures/azure_terraform/test_vm_vmss --show
# Example 3: From a public Git repository and only look at subfolder /aws/wordpress_fargate (note double slash)
terravision draw --source https://github.com/patrickchugh/terraform-examples.git//aws/wordpress_fargate --showThat's it! Your diagram is saved as architecture.png and automatically opened.
# Generate diagram from your Terraform directory
terravision draw --source /path/to/your/terraform/code# Generate a JSON graph file as output (default file is architecture.json)
terravision graphdata --source tests/fixtures/aws_terraform/ecs-ec2
# Draw a diagram from a simple pre-existing JSON graph file
terravision draw --source tests/json/bastion-expected.jsonDetailed installation instructions: See docs/INSTALLATION.md
# From local Terraform directory
terravision draw --source ./terraform
# From Git repository
terravision draw --source https://github.com/user/repo.git
# With custom output format
terravision draw --source ./terraform --format svg --outfile my-architecture
# Open diagram automatically
terravision draw --source ./terraform --show| Option | Description | Example |
|---|---|---|
--source |
Terraform code location | ./terraform or Git URL |
--format |
Output format | png, svg, pdf, bmp |
--outfile |
Output filename | architecture (default) |
--workspace |
Terraform workspace | production, staging |
--varfile |
Variable file | prod.tfvars |
--show |
Open diagram after generation | (flag) |
--debug |
Enable debug output | (flag) |
# Export resource relationships as JSON
terravision graphdata --source ./terraform --outfile resources.jsonMore examples: See docs/USAGE_GUIDE.md
- Installation Guide - Detailed setup instructions
- Usage Guide - Commands, options, and examples
- Annotations Guide - Customize your diagrams
- CI/CD Integration - Automate diagram generation
- Troubleshooting - Common issues and solutions
- Resource Handler Guide - Handler architecture
- Contributing Guide - How to contribute
- Developer Guide - Development setup
- AI-Powered Refinement - Using AI to improve diagrams
- Performance Optimization - Tips for large projects
| Provider | Status | Resources Supported |
|---|---|---|
| AWS | β Full Support | 200+ services |
| Google Cloud | π Partial Support | Core Services |
| Azure | π Partial Support | Core services |
graph LR
A["π Source Code<br/>Checked into Git"] --> B["π§ͺ Test"]
B --> C["π¨ Build/Deploy"]
C --> D["π Generate Diagrams<br/>TerraVision"]
D --> E["π Document"]
style A fill:#e1f5ff
style B fill:#fff3e0
style C fill:#f3e5f5
style D fill:#e8f5e9
style E fill:#fce4ec
Use the official TerraVision Action:
# .github/workflows/architecture-diagrams.yml
name: Update Architecture Diagrams
on:
push:
branches: [main]
paths: ['**.tf', '**.tfvars']
jobs:
generate-diagrams:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- uses: patrickchugh/terravision-action@v1
with:
source: ./infrastructure
outfile: docs/architecture
format: both
- name: Commit Diagrams
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/architecture.*
git commit -m "Update architecture diagrams [skip ci]" || exit 0
git pushUse the Docker image directly β no additional setup needed:
# GitLab CI example
generate-diagram:
image: patrickchugh/terravision:latest
script:
- terravision draw --source ./infrastructure --outfile architecture --format png
artifacts:
paths:
- architecture.pngFull CI/CD guide (GitHub, GitLab, Jenkins, Azure DevOps, generic): See docs/CICD_INTEGRATION.md
We welcome contributions! See CONTRIBUTING.md for:
- Code of conduct
- Development setup
- Pull request process
- Coding standards
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: docs/
Refer to LICENSE text file
TerraVision uses:



