Generate interactive architecture diagrams from Terraform configurations
Project description
terraformgraph
Generate interactive architecture diagrams from your Terraform configurations. Supports AWS resources with automatic service grouping, relationship detection, and beautiful SVG/HTML output.
Features
- Automatic parsing of Terraform HCL files
- Smart resource grouping into logical services (ECS, RDS, S3, etc.)
- Relationship detection based on resource references
- Interactive HTML output with drag-and-drop positioning
- PNG/JPG export directly from the browser
- Customizable via YAML configuration files
- No cloud credentials required - works entirely offline
Installation
From PyPI
pip install terraformgraph
From Source
git clone https://github.com/ferdinandobons/terraformgraph.git
cd terraformgraph
pip install -e .
Quick Start
Basic Usage
Generate a diagram from a Terraform directory:
terraformgraph -t ./infrastructure
This creates diagram.html in the current directory.
With Environment Subdirectories
If your Terraform is organized by environment:
terraformgraph -t ./infrastructure -e prod -o prod-diagram.html
With AWS Icons
For beautiful AWS service icons, download the AWS Architecture Icons and extract them:
terraformgraph -t ./infrastructure -i ./AWS_Icons
Command Line Options
| Option | Required | Description |
|---|---|---|
-t, --terraform |
Yes | Path to Terraform directory |
-e, --environment |
No | Environment subdirectory (dev, staging, prod) |
-i, --icons |
No | Path to AWS icons directory |
-o, --output |
No | Output HTML file path (default: diagram.html) |
-v, --verbose |
No | Enable debug output |
Configuration
Custom Aggregation Rules
Create ~/.terraformgraph/aggregation_rules.yaml to customize how resources are grouped:
compute:
my_custom_service:
primary: ["aws_my_resource"]
secondary: ["aws_my_helper"]
in_vpc: true
Custom Connections
Create ~/.terraformgraph/logical_connections.yaml to define service relationships:
connections:
- source: my_service
target: another_service
label: "Custom Connection"
type: data_flow
Supported Resources
The tool supports 100+ AWS resource types including:
- Compute: ECS, EC2, Lambda, Auto Scaling
- Networking: VPC, ALB/NLB, Route53, CloudFront
- Storage: S3, EBS, EFS
- Database: RDS, DynamoDB, ElastiCache
- Messaging: SQS, SNS, EventBridge
- Security: IAM, KMS, Secrets Manager, WAF
- And many more...
Output
The generated HTML file includes:
- Interactive diagram with pan and zoom
- Drag-and-drop to reposition services
- Click connections to highlight data flows
- Export buttons for PNG and JPG
- Save/Load layout using browser storage
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terraformgraph-1.0.3.tar.gz.
File metadata
- Download URL: terraformgraph-1.0.3.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f514cb608ec7601600d3c7f19a42fb5c9e8f58bfaaff9eb13cfe350c5b8d640
|
|
| MD5 |
a8d5f644c617309fb49b3bfaf4c1aeda
|
|
| BLAKE2b-256 |
31e3818d399c2c728cbcc01d5d80d537d476a9e245466e64fe6db5f1d9a23fe6
|
File details
Details for the file terraformgraph-1.0.3-py3-none-any.whl.
File metadata
- Download URL: terraformgraph-1.0.3-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3b7571eed6c5d94f8394bd57f5453c97f5b239c4a1ed8df46c46f23905635ce
|
|
| MD5 |
0d4eaa2eb1edbee57bdd1c62f2dcaade
|
|
| BLAKE2b-256 |
e0dfc104a579d8b39807bafc9132202d7c438d9ec88e25b843416f76ab7b69f5
|