Skip to content

Repository files navigation

Diagrams with Python

English · Español


English

Collection of infrastructure diagrams built as code with Diagrams (Python). The idea is to keep visuals reproducible and aligned with what you define in tools like Terraform, so documentation stays clear and easy to refresh.

Diagram examples

AWS diagram example (project-4) AWS diagram from JSON config
CI/CD Bitbucket Azure DevOps AWS

Repository layout

Diagrams.With.Python/
├── requirements.txt
├── examples/                         # Shared PNG gallery (samples, CI/CD, diagram-terra)
├── samples/                          # Small AWS topologies + JSON-driven diagram
│   ├── config.json
│   ├── json-read.py
│   ├── project-2.py … project-5.py
│   └── rds-ec2.py
├── ci-cd/                            # Bitbucket → Azure DevOps → AWS (QA develop / Prod master)
│   └── ci-cd-bitbucket-azure-aws.py
├── multi-region-dr/                  # Route 53 failover across two AWS regions
│   └── route53-failover.py
├── diagram-terra/                    # Larger AWS / Azure DevOps style diagram
│   └── diagram-terra.py
├── big-diagram/                      # Extended gateway topology (+ local config.json)
├── ec2-backup-with-s3/               # EC2 → S3 backup
├── ecs-fargate/                      # ECS Fargate
└── with-docker/                      # Docker-related diagram (+ local config.json)
Folder Script Output
samples/ project-4.py examples/project-4.png
samples/ json-read.py examples/project-json.png
ci-cd/ ci-cd-bitbucket-azure-aws.py examples/ci-cd-bitbucket-azure-aws.png
multi-region-dr/ route53-failover.py examples/multi-region-dr.png
diagram-terra/ diagram-terra.py examples/diagram-terra.png
big-diagram/ with-gateway.py big-diagram/with-gateway-diagram.png
ec2-backup-with-s3/ backup.py ec2-backup-with-s3/backup.png
ecs-fargate/ fargate.py ecs-fargate/diagram.png
with-docker/ with-dockers.py with-docker/with-dockers-diagram.png

Prerequisites

  • Python 3.x
  • Graphviz installed on the system (required by Diagrams). On Windows, the installer often leaves dot off your PATH; add C:\Program Files\Graphviz\bin to the user PATH and open a new terminal, or run once per session in PowerShell: $env:Path = "C:\Program Files\Graphviz\bin;" + $env:Path
  • Python dependencies (pinned in requirements.txt):
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS / Linux: source .venv/bin/activate
pip install -r requirements.txt

How to run

Scripts resolve config and output paths from their own location, so you can run them from any working directory:

python samples/project-4.py
# Writes: examples/project-4.png

python ci-cd/ci-cd-bitbucket-azure-aws.py
# Writes: examples/ci-cd-bitbucket-azure-aws.png

Besides the PNG, Diagrams may leave a Graphviz source file next to it (same base name, often without a .dot extension). You can delete those files and regenerate them by running the script again.

Tips

  • In Diagram(...), show=True opens the image with the default viewer after generation; use show=False to only write the file.
  • Getting started and layout options: Diagrams — Getting started. AWS node catalog: AWS nodes.

Version: 0.2.0

License

Released under the MIT License. Copyright (c) 2026 Agustina Fassina.


Español

Conjunto de diagramas de infraestructura definidos como código con Diagrams en Python. El objetivo es que los gráficos sean reproducibles y coherentes con lo que definís en Terraform (u otras fuentes), para documentar de forma clara y actualizable.

Ejemplos de diagramas

Ejemplo de diagrama AWS (project-4) Diagrama AWS desde JSON
CI/CD Bitbucket Azure DevOps AWS

Estructura del repositorio

Diagrams.With.Python/
├── requirements.txt
├── examples/                         # Galería PNG compartida (samples, CI/CD, diagram-terra)
├── samples/                          # Topologías AWS pequeñas + diagrama desde JSON
│   ├── config.json
│   ├── json-read.py
│   ├── project-2.py … project-5.py
│   └── rds-ec2.py
├── ci-cd/                            # Bitbucket → Azure DevOps → AWS (QA develop / Prod master)
│   └── ci-cd-bitbucket-azure-aws.py
├── multi-region-dr/                  # Failover Route 53 entre dos regiones AWS
│   └── route53-failover.py
├── diagram-terra/                    # Diagrama amplio AWS / Azure DevOps
│   └── diagram-terra.py
├── big-diagram/                      # Topología con gateway (+ config.json local)
├── ec2-backup-with-s3/               # Backup EC2 → S3
├── ecs-fargate/                      # ECS Fargate
└── with-docker/                      # Diagrama con Docker (+ config.json local)
Carpeta Script Salida
samples/ project-4.py examples/project-4.png
samples/ json-read.py examples/project-json.png
ci-cd/ ci-cd-bitbucket-azure-aws.py examples/ci-cd-bitbucket-azure-aws.png
multi-region-dr/ route53-failover.py examples/multi-region-dr.png
diagram-terra/ diagram-terra.py examples/diagram-terra.png
big-diagram/ with-gateway.py big-diagram/with-gateway-diagram.png
ec2-backup-with-s3/ backup.py ec2-backup-with-s3/backup.png
ecs-fargate/ fargate.py ecs-fargate/diagram.png
with-docker/ with-dockers.py with-docker/with-dockers-diagram.png

Requisitos

  • Python 3.x
  • Graphviz instalado en el sistema (lo exige la librería Diagrams). En Windows, si aparece ExecutableNotFound: failed to execute WindowsPath('dot'), agregá C:\Program Files\Graphviz\bin al PATH del usuario y abrí una terminal nueva, o en PowerShell por sesión: $env:Path = "C:\Program Files\Graphviz\bin;" + $env:Path
  • Dependencias de Python (versiones fijadas en requirements.txt):
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS / Linux: source .venv/bin/activate
pip install -r requirements.txt

Cómo ejecutar

Los scripts resuelven config y salidas desde su propia ubicación, así que podés ejecutarlos desde cualquier directorio de trabajo:

python samples/project-4.py
# Genera: examples/project-4.png

python ci-cd/ci-cd-bitbucket-azure-aws.py
# Genera: examples/ci-cd-bitbucket-azure-aws.png

Además del PNG, Diagrams puede dejar el fuente Graphviz al lado (mismo nombre, a veces sin extensión .dot). Podés borrarlo y regenerarlo volviendo a ejecutar el script.

Comentarios y recomendaciones

  • En Diagram(...), show=True abre la imagen con el visor predeterminado al terminar; con show=False solo se guarda el archivo.
  • Intro e instalación: Diagrams — Getting started. Catálogo de nodos AWS: AWS nodes.

Versión: 0.2.0

About

This repository contains Python-generated diagrams to visualize and replicate our Terraform infrastructure automatically and keep documentation up-to-date.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages