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.

๐ŸŽฏ 2-Minute Quick Start

Step 1: Add the unified workflow to your repository:

# .github/workflows/r2d-unified.yml
name: R2D - DevOps in a Box
on:
  issues:
    types: [opened, edited]
  pull_request:
    types: [closed]
  workflow_dispatch:
    inputs:
      repo_url:
        description: 'Repository URL to deploy'
        required: false
        type: string

jobs:
  r2d-deploy:
    uses: amartyamandal/diagram-to-iac/.github/workflows/r2d-unified.yml@main
    secrets: inherit
    with:
      repo_url: ${{ inputs.repo_url || github.server_url }}/${{ github.repository }}

Step 2: Configure your secrets (see complete guide)

Step 3: Trigger deployment via issue, PR merge, or manual run

๐Ÿ“š Complete Setup Guide - Everything you need in one place!

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

The R2D system now uses a unified workflow that handles all deployment scenarios automatically. This replaces the previous multiple workflow files with a single, intelligent solution.

โšก Simple Setup (Recommended)

Add this single workflow file to get all R2D capabilities:

# .github/workflows/r2d-unified.yml
name: R2D - DevOps in a Box
on:
  issues:
    types: [opened, edited]
  pull_request:
    types: [closed]
  workflow_dispatch:
    inputs:
      repo_url:
        description: 'Repository URL to deploy'
        required: false
        type: string

jobs:
  r2d-deploy:
    uses: amartyamandal/diagram-to-iac/.github/workflows/r2d-unified.yml@main
    secrets: inherit
    with:
      repo_url: ${{ inputs.repo_url || github.server_url }}/${{ github.repository }}

๐ŸŽฎ Multiple Ways to Deploy

  • ๐Ÿ“ Issue-based: Create an issue with "deploy" in title/body
  • ๐Ÿ”€ PR merge: Automatic deployment when PRs are merged
  • ๐ŸŽฏ Manual: Use workflow_dispatch with optional custom repo URL
  • ๐Ÿ”’ External repos: Deploy any accessible repository

๐Ÿ“‹ Required Secrets

Configure these in your repository settings โ†’ Secrets and variables โ†’ Actions:

Secret Description Required
GITHUB_TOKEN GitHub API access (auto-provided) โœ… Yes
TF_CLOUD_TOKEN Terraform Cloud workspace token โœ… Yes
OPENAI_API_KEY OpenAI API key for AI features โŒ Optional
ANTHROPIC_API_KEY Claude API key for AI features โŒ Optional
DOCKERHUB_USERNAME DockerHub username for private containers โŒ Optional
DOCKERHUB_TOKEN DockerHub access token for private containers โŒ Optional

๐Ÿ“š Complete Setup Guide includes examples, troubleshooting, and advanced configurations.

Note: The system automatically maps TF_CLOUD_TOKEN to the internal TFE_TOKEN environment variable. DockerHub: Only needed if using private container registries.

๐Ÿ“ˆ Observability & Monitoring

After each workflow run, comprehensive artifacts are generated:

  • ๐Ÿ“Š Step Summary Dashboard: step-summary.md with Terraform changes, security findings, and metrics
  • ๐Ÿ“‹ Structured Logs: JSONL format in logs/ directory for analysis
  • ๐Ÿ” GitHub Integration: Automatic issue creation and PR suggestions
  • ๐Ÿ“ฆ Artifacts: Plans, reports, and logs uploaded as GitHub Actions artifacts

๐Ÿงช Development & Testing

For local development and testing:

# Install development dependencies
pip install -e .[dev]

# Run the CLI locally
diagram-to-iac https://github.com/user/repo --dry-run

# Run tests
pytest

๐Ÿ“š Documentation

๐ŸŽฏ THE ONLY GUIDE YOU NEED: Definitive Integration Guide

All other documentation is for reference only. Start with the guide above.

Reference Documentation

๐Ÿค Contributing

This project follows strict coding standards and security practices. See the development guidelines in the repository for contribution instructions.


"One container, many mindsโ€”zero manual toil." ๐Ÿค–

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.14.0.tar.gz (243.9 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.14.0-py3-none-any.whl (190.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: diagram_to_iac-1.14.0.tar.gz
  • Upload date:
  • Size: 243.9 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.14.0.tar.gz
Algorithm Hash digest
SHA256 9dba7a1fae762c50dc09e31ed7ff9ea0dbddc61d70e4476606a2a3c3ca2290de
MD5 bd446151fb0c0b1e616cfd63d6f8d01c
BLAKE2b-256 a5d27bb489c4d530aeac2d78434bd7cff4f2311bb26c9de3a8fc35948851135b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diagram_to_iac-1.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84a2dfc94170c63eb02b87c89b383954273411ee71dc4278b857147457795c5d
MD5 d338355e61c8b3ed3c0568862d938a03
BLAKE2b-256 e1f9104e089fd349423cf1287dd748f600aea9b45f12dd414be3059037149b8c

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