Convert architecture diagrams into IaC modules
Project description
diagram-to-iac
"One container, many mindsโzero manual toil."
An automated DevOps-in-a-Box system that intelligently handles complete Repo-to-Deployment (R2D) workflows. The project combines AI-powered infrastructure analysis with GitHub automation for self-healing deployments.
๐ DevOps-in-a-Box: R2D Action
The R2D (Repo-to-Deployment) Action is a self-healing, Terraform-first DevOps automation solution that lives inside a single GitHub Action. When you supply any repository URL, our SupervisorAgent marshals specialized agents to handle the complete deployment workflow.
Quick Start with GitHub Actions
name: Deploy Infrastructure
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy with R2D
uses: amartyamandal/diagram-to-iac/.github/actions/r2d@v1
with:
repo: ${{ github.server_url }}/${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_CLOUD_TOKEN: ${{ secrets.TF_CLOUD_TOKEN }}
Key Features
- ๐ค Self-Healing: Automatically creates GitHub Issues for errors and suggests fixes
- ๐ Security-First: Non-root container execution with workspace isolation
- ๐ Multi-Cloud: Supports Terraform, PowerShell, Bash, and Ansible deployments
- ๐ Observable: Rich logging, step summaries, and artifact collection
- ๐ Resumable: Thread-based conversation tracking for workflow continuation
- ๐งช Testable: Comprehensive dry-run mode for safe testing
The Cast: Specialized Agents
| Agent | Capability | Never Does |
|---|---|---|
| SupervisorAgent | Orchestrates workflow, manages checkpoints | Edit code directly |
| GitAgent | Clone, branch, PR creation, assign @github-copilot | Guess network credentials |
| ShellAgent | Safe command execution, stack detection | Execute non-allowlisted binaries |
| TerraformAgent | Init/plan/apply, error classification | Apply with critical security issues |
| PolicyAgent | tfsec + OPA security gates | Ignore critical findings |
๐ฆ Installation
Create a virtual environment with Python 3.11+ and install the project in editable mode. Development dependencies (linting, testing, etc.) are provided through the dev extra:
pip install -e .[dev]
๐ฅ๏ธ Running the CLI
The project exposes several entry points via pyproject.toml:
Main R2D CLI
# Run complete R2D workflow
diagram-to-iac https://github.com/user/repo
r2d-agent https://github.com/user/repo --dry-run
# Get help
diagram-to-iac --help
Individual Agent CLIs
# SupervisorAgent (orchestration)
supervisor-agent --repo-url https://github.com/user/repo
# GitAgent (repository operations)
git-agent --repo-url https://github.com/user/repo
# TerraformAgent (infrastructure deployment)
terraform-agent --query "terraform plan"
Interactive Mode
Running without arguments enters interactive mode:
$ supervisor-agent --dry-run
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค DevOps-in-a-Box: SupervisorAgent โ
โ "One container, many mindsโzero manual toil." โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Repository URL: https://github.com/octocat/Hello-World.git
๐ R2D SupervisorAgent - Workflow Orchestration
๐
Default branch name: r2d-<timestamp>
๐ Press Enter to use default, or type a custom branch name:
The agent will continue with the complete workflow (clone โ detect โ deploy โ issue creation). The --dry-run flag simulates actions without making changes.
Running Tests
All tests use pytest and are located under the tests directory. After installing the development dependencies, run:
pytest
๐ Logs and Observability
DevOps-in-a-Box provides comprehensive observability for all R2D workflows:
Structured Logging
Each run creates a JSONL log file under the logs/ directory (e.g. logs/run-<timestamp>.jsonl).
Every significant event is logged as structured JSON for easy parsing and analysis:
# Follow live logs
tail -f logs/run-*.jsonl
# Parse with jq for specific events
cat logs/run-*.jsonl | jq '. | select(.event_type == "terraform_apply")'
Step Summary Dashboard
After each workflow, a Markdown dashboard is generated at step-summary.md with:
- ๐ Terraform resource changes and cost estimates
- ๐ Security findings from tfsec/OPA scans
- ๐๏ธ Infrastructure modules and dependencies
- โก Performance metrics and execution times
GitHub Integration
- Issues: Automatically created for errors with detailed context
- Pull Requests: Auto-drafted fixes assigned to @github-copilot
- Workflow Summaries: Rich GitHub Actions step summaries
- Artifacts: Logs, plans, and reports uploaded for download
CI/CD Artifacts
In GitHub Actions, the following artifacts are automatically collected:
logs/- Structured JSONL logs*.tfplan- Terraform plan filesstep-summary.md- Workflow dashboardr2d-artifacts/- Complete workflow artifacts
๐ง GitHub Actions Usage
Add the R2D action to your workflow for automated infrastructure deployment:
Basic Setup
name: Deploy Infrastructure
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy with R2D
uses: amartyamandal/diagram-to-iac/.github/actions/r2d@v1
with:
repo: ${{ github.server_url }}/${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_CLOUD_TOKEN: ${{ secrets.TF_CLOUD_TOKEN }}
Advanced Configuration
- name: Deploy with Custom Settings
uses: amartyamandal/diagram-to-iac/.github/actions/r2d@v1
with:
repo: 'https://github.com/my-org/infrastructure'
package_version: 'v2.1.0'
dry_run: 'false'
branch_name: 'deploy-prod'
thread_id: 'prod-deployment-001'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_CLOUD_TOKEN: ${{ secrets.TF_CLOUD_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Required Secrets
Configure these in your repository settings:
| Secret | Description | Required |
|---|---|---|
GITHUB_TOKEN |
GitHub API access (auto-provided) | โ Yes |
TF_CLOUD_TOKEN |
Terraform Cloud API token | โ Yes |
OPENAI_API_KEY |
OpenAI API key | โ Optional |
ANTHROPIC_API_KEY |
Claude API key | โ Optional |
GOOGLE_API_KEY |
Gemini API key | โ Optional |
Example Workflows
See .github/actions/r2d/examples/ for complete workflow examples:
- Basic Deployment: Simple push-to-deploy workflow
- Multi-Environment: Deploy to dev/staging/prod with approvals
- PR Validation: Validate infrastructure changes in pull requests
- Drift Detection: Scheduled infrastructure drift monitoring
- External Repository: Deploy from external repositories
After each workflow run, a Markdown dashboard is generated at step-summary.md
showing a high level overview of Terraform modules, resource changes and tfsec
findings. The dashboard is derived from the JSONL logs and can be viewed
directly in the repository or uploaded as a build artifact.
This repository provides a container action that runs the SupervisorAgent on the current repository. Add the action to a workflow as shown below:
jobs:
supervisor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Supervisor Agent
uses: ./.github/actions/supervisor
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The action reads GITHUB_REPOSITORY and GITHUB_TOKEN automatically to clone the repository and execute the agent.
Project details
Release history Release notifications | RSS feed
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 diagram_to_iac-0.14.0.tar.gz.
File metadata
- Download URL: diagram_to_iac-0.14.0.tar.gz
- Upload date:
- Size: 114.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71a4e1f1f8bb3786fb9b2cb80dfac24dfa704c9e89f518d50d46129186268b28
|
|
| MD5 |
8d5b9e0789445fd27ad9c49619938d2c
|
|
| BLAKE2b-256 |
c9be3ad9b97c7004ce3ced34f853f34e778ebeb1d3696aa4853964f12d5bd6f6
|
File details
Details for the file diagram_to_iac-0.14.0-py3-none-any.whl.
File metadata
- Download URL: diagram_to_iac-0.14.0-py3-none-any.whl
- Upload date:
- Size: 135.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fa860f4a4d98780611fc4c3d18e5374a515f53f393fa1ac1c82a04cf663a9d2
|
|
| MD5 |
a4fc36d1c2ca6e25e8428699d84195ed
|
|
| BLAKE2b-256 |
b4b640a9f16d01e98cee3ff503b8edf34d614cc52e28157ab26ef60ce3c1602b
|