Skip to main content

Terraform Architecture Visualizer

Project description

TerraVision

AI-Powered Terraform to Architecture Diagram Generator

lint-and-test

⚠️ Alpha Software Notice
This software is in alpha testing. Code is shared "AS IS" without warranties. Use at your own risk.


Table of Contents


What is TerraVision?

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:

Terraform Code

Into this architecture diagram:

Why TerraVision?

  • 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 your pipeline with simple CLI interface
  • Free & Open Source: No expensive diagramming tool licenses
  • Multi-Cloud: Supports AWS, GCP, and Azure

Key Features

🎨 Professional Diagrams

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

🤖 AI-Powered Refinement

  • Automatically fixes resource relationships
  • Adds missing logical connections, labels, titles and icons as needed
  • Ensures architectural diagramming best practices

📝 Customizable Annotations

  • Add custom labels and titles
  • Include external resources not in Terraform
  • Override automatic connections

🔄 CI/CD Integration

  • GitHub Actions, GitLab CI, Jenkins support
  • Show multiple environments using TF Variables to document variants of your infrastructure (e.g. prod vs dev)

🔒 Secure & Private

  • No cloud credentials required
  • Runs entirely on your local machine
  • No external API calls (except optional AI features)

Quick Start

Prerequisites

Before installing TerraVision, ensure you have:

Install TerraVision

# Clone repository
git clone https://github.com/patrickchugh/terravision.git
cd terravision

# Install dependencies
pip install -r requirements.txt

Verify Terraform Setup

Before 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/ or gcp_terraform/
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, but TerraVision itself never accesses your cloud account.

Important for Terraform Enterprise 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.

Try It Out!

Generate your first diagram using our example Terraform code:

# Example 1: EKS cluster with managed nodes and OIDC
./terravision.py draw --source tests/fixtures/aws_terraform/eks_managed_nodes --show

# Example 2: Step Functions orchestrating multiple services
./terravision.py draw --source tests/fixtures/aws_terraform/stepfunctions_multi_service --show

# Example 3: SageMaker notebook in VPC with security
./terravision.py draw --source tests/fixtures/aws_terraform/sagemaker_notebook_vpc --show

# Example 4: From a public Git repository and only look at subfolder /aws/wordpress_fargate (note double slash)
./terravision.py draw --source https://github.com/patrickchugh/terraform-examples.git//aws/wordpress_fargate --show

That's it! Your diagram is saved as architecture.png and automatically opened.

Use Your Own Terraform Code

# Generate diagram from your Terraform directory
./terravision.py draw --source /path/to/your/terraform/code

Installation

Method 1: Quick Install (Recommended for Users)

macOS/Linux:

git clone https://github.com/patrickchugh/terravision.git
cd terravision
pip install -r requirements.txt
chmod +x terravision.py
ln -s $(pwd)/terravision.py $(pwd)/terravision
export PATH=$PATH:$(pwd)

Windows:

git clone https://github.com/patrickchugh/terravision.git
cd terravision
pip install -r requirements.txt
echo @python "%~dp0terravision.py" %* > terravision.bat
copy terravision.bat C:\Windows\System32\

Method 2: Poetry Install (Recommended for Developers)

# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -

# Install TerraVision
git clone https://github.com/patrickchugh/terravision.git
cd terravision
poetry install
source $(poetry env info --path)/bin/activate

Detailed installation instructions: See docs/INSTALLATION.md


Basic Usage

Generate a Diagram

# 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

Common Options

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 Graph Data

# Export resource relationships as JSON
terravision graphdata --source ./terraform --outfile resources.json

More examples: See docs/USAGE_GUIDE.md


Documentation

For Users

For Developers

Advanced Topics


Supported Cloud Providers

Provider Status Resources Supported
AWS ✅ Full Support 200+ services
Google Cloud 🔄 Coming Soon Core services
Azure 🔄 Partial Support Core services

CI/CD Integration Example

Pipeline Workflow

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
# .github/workflows/architecture-diagrams.yml
name: Update Architecture Diagrams

on:
  push:
    branches: [main]
    paths: ['**.tf']

jobs:
  generate-diagrams:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Install Dependencies
        run: |
          sudo apt-get install -y graphviz
          pip install -r requirements.txt
      - name: Generate Diagrams
        run: |
          terravision draw --source ./terraform --format svg
          terravision draw --source ./terraform --format png
      - name: Commit Diagrams
        run: |
          git config user.name "GitHub Actions"
          git add docs/images/*.{svg,png}
          git commit -m "Update architecture diagrams" || exit 0
          git push

More CI/CD examples: See docs/CICD_INTEGRATION.md


Contributing

We welcome contributions! See CONTRIBUTING.md for:

  • Code of conduct
  • Development setup
  • Pull request process
  • Coding standards

Support


License

Refer to LICENSE text file


Acknowledgments

TerraVision uses:

  • Graphviz for diagram rendering
  • Terraform for infrastructure parsing
  • Cloud provider icons from official sources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terravision-0.9.4.tar.gz (20.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terravision-0.9.4-py3-none-any.whl (21.2 MB view details)

Uploaded Python 3

File details

Details for the file terravision-0.9.4.tar.gz.

File metadata

  • Download URL: terravision-0.9.4.tar.gz
  • Upload date:
  • Size: 20.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0

File hashes

Hashes for terravision-0.9.4.tar.gz
Algorithm Hash digest
SHA256 1961aa834efb8c264f7b90f99dd0782f1d4db26f7c06f9556026d4cf48e11a64
MD5 ee067b2f92ea411defce28a98a507639
BLAKE2b-256 06defe17a82f0b80f8a6336ff473b2ef8af6bf87c17c9019d1236cd76acd5d92

See more details on using hashes here.

File details

Details for the file terravision-0.9.4-py3-none-any.whl.

File metadata

  • Download URL: terravision-0.9.4-py3-none-any.whl
  • Upload date:
  • Size: 21.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0

File hashes

Hashes for terravision-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab486a659673452065a96999689db7a564365b990ed1e317de3b902490e46e8
MD5 b4737c7f2e692d7f6f01dca1d64bb26a
BLAKE2b-256 5fcbb6a293e03fc4c431ac307836ebd169d6657105ee7c0f9d16f97d8c84411e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page