Metadata-Version: 2.4
Name: terraformgraph
Version: 1.0.2
Summary: Generate interactive architecture diagrams from Terraform configurations
Author-email: Your Name <your.email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/ferdinandobons/terraformgraph
Project-URL: Documentation, https://github.com/ferdinandobons/terraformgraph#readme
Project-URL: Repository, https://github.com/ferdinandobons/terraformgraph.git
Project-URL: Issues, https://github.com/ferdinandobons/terraformgraph/issues
Keywords: terraform,infrastructure,diagram,aws,visualization,architecture,terraformgraph
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-hcl2>=4.3.0
Requires-Dist: PyYAML>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: types-PyYAML>=6.0; extra == "dev"
Dynamic: license-file

# terraformgraph

Generate interactive architecture diagrams from your Terraform configurations. Supports AWS resources with automatic service grouping, relationship detection, and beautiful SVG/HTML output.

![Example Diagram](docs/diagram.png)

## 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

```bash
pip install terraformgraph
```

### From Source

```bash
git clone https://github.com/ferdinandobons/terraformgraph.git
cd terraformgraph
pip install -e .
```

## Quick Start

### Basic Usage

Generate a diagram from a Terraform directory:

```bash
terraformgraph -t ./infrastructure
```

This creates `diagram.html` in the current directory.

### With Environment Subdirectories

If your Terraform is organized by environment:

```bash
terraformgraph -t ./infrastructure -e prod -o prod-diagram.html
```

### With AWS Icons

For beautiful AWS service icons, download the [AWS Architecture Icons](https://aws.amazon.com/architecture/icons/) and extract them:

```bash
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:

```yaml
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:

```yaml
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](CONTRIBUTING.md) for guidelines.

## License

MIT License - see [LICENSE](LICENSE) for details.
