Skip to main content

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 files
  • step-summary.md - Workflow dashboard
  • r2d-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


Download files

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

Source Distribution

diagram_to_iac-1.0.3.tar.gz (126.6 kB view details)

Uploaded Source

Built Distribution

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

diagram_to_iac-1.0.3-py3-none-any.whl (145.6 kB view details)

Uploaded Python 3

File details

Details for the file diagram_to_iac-1.0.3.tar.gz.

File metadata

  • Download URL: diagram_to_iac-1.0.3.tar.gz
  • Upload date:
  • Size: 126.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for diagram_to_iac-1.0.3.tar.gz
Algorithm Hash digest
SHA256 394753807e7482dcbfd57e19c3701ee57664c6d6a01695730befadd6c6020137
MD5 c0be7428fb05714be88059f47b92090a
BLAKE2b-256 1f79c25ea0a21b78de97a3b0acb35fb6b7ac83d8dda1d47ca69359f807d01518

See more details on using hashes here.

File details

Details for the file diagram_to_iac-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: diagram_to_iac-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 145.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for diagram_to_iac-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e12c60cf30bc4449d76657ccc181d63409c85f2706840c13a1a428a5419ba714
MD5 6a7efaf3007d7ebccc45bacd9fce1f25
BLAKE2b-256 64792f040923e36254fe7e1d2d123c267a61dbcfa7adb2fdcc1e4024595cbf35

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