Analyzes Infrastructure as Code files (Terraform, CloudFormation, Kubernetes, Docker Compose) and generates visual architecture diagrams. Use when analyzing infrastructure code, designing cloud architectures, or when the user requests architecture diagrams from IaC.
Analyzes Infrastructure as Code repositories and generates professional architecture diagrams using Nano Banana Pro. Supports Terraform, CloudFormation, Kubernetes, Docker Compose, Pulumi, and other common IaC formats.
Infrastructure diagrams should accurately represent the logical architecture, resource relationships, and security boundaries defined in your IaC. This skill parses IaC files to extract resources, dependencies, and hierarchical structures, then generates diagrams that follow cloud architecture best practices.
When a user requests an architecture diagram from IaC files, follow these steps:
Use Glob to identify IaC files in the target directory:
*.tf, *.tfvars*.yaml, , , *.yml*.json*.template*.yaml, *.yml (in manifests/, k8s/, kube/ directories)docker-compose.yaml, docker-compose.yml*.ts, *.py, *.go (with Pulumi imports)*.json (with ARM schema)*.yaml, *.jinja, *.pyIf no specific file is mentioned, search the current directory recursively.
Run the appropriate parser script based on file type. The parser accepts local paths or GitHub repository URLs.
Local files/directories:
# Terraform
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform path/to/terraform/dir
# CloudFormation
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py cloudformation path/to/template.yaml
# Kubernetes
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py kubernetes path/to/manifests/
# Docker Compose
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py docker-compose path/to/docker-compose.yaml
GitHub repositories (cloned automatically):
# Clone entire repo and parse
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform https://github.com/user/repo
# Clone and parse specific subdirectory
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform https://github.com/user/repo/tree/main/infrastructure
# Short format also works
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform github.com/user/repo
Supported GitHub URL formats:
https://github.com/user/repohttps://github.com/user/repo/tree/branch/path/to/dirgithub.com/user/repo[email protected]:user/repoThe parser automatically clones the repo to a temp directory, parses the files, and cleans up after.
The parser will return a JSON structure containing:
Review the parsed structure to understand:
Create a detailed, structured prompt for Nano Banana Pro that describes the architecture diagram using natural language. Follow these guidelines carefully to ensure consistent, visually stunning results.
Every diagram MUST follow this standardized visual template for consistency:
Canvas & Outer Margins:
Border Frame (Inside the outer margin):
Header Section (Inside the frame, top 12%):
Main Canvas (Inside the frame, middle 78%):
Footer Section (Inside the frame, bottom 10%):
Use Isometric 3D Style (NOT flat official icons):
Color Palette for Icons:
Zone/Layer Backgrounds:
Describe the architecture from outermost to innermost layers:
Cloud Provider / Region Level
VPC / Virtual Network Level
Availability Zone / Subnet Level
Resource Level
For each resource type, use appropriate descriptions:
Compute:
Networking:
Storage:
Security:
Describe how resources connect using consistent visual styling:
Connection Arrow Styles:
Connection Color Coding:
Connection Labels:
Data Flow Direction:
Critical - Specify Exact Text:
Orientation:
Spacing and Clarity:
Three-Tier Web Application:
A professional 16:9 landscape cloud architecture diagram in a stunning modern infographic style.
CANVAS AND MARGINS:
The image has a generous white outer margin (at least 60 pixels on all sides) so no content approaches the page edges. Inside this margin, a subtle rounded-corner border with a thin charcoal stroke frames the entire diagram. All content is contained inside this border with comfortable inner padding.
HEADER (inside the frame):
A gradient header bar spans the top inside the frame, transitioning from deep navy blue on the left to teal on the right. The title 'Three-Tier Web Application' appears in large, bold white sans-serif text centered in the header. A subtitle below reads 'AWS Production Environment • us-east-1' in smaller light blue text.
MAIN CANVAS:
The main area has a very light cool gray background. The layout flows left-to-right showing the request path from internet to database. Generous spacing between all elements.
VISUAL STYLE:
All icons are rendered in a clean isometric 3D style with subtle drop shadows and soft gradient fills. Icons are crisp, detailed, and visually appealing like high-end tech infographic illustrations. Each resource type uses harmonious colors from a modern palette.
ARCHITECTURE ZONES (arranged left to right):
ZONE 1 - Internet Entry (far left):
A small cloud icon labeled 'Internet' with a globe symbol. A bright blue curved arrow flows rightward.
ZONE 2 - Public Layer (light blue tinted rectangle with dashed blue border, labeled 'Public Subnet 10.0.1.0/24'):
- A purple isometric Internet Gateway icon with network symbol
- A purple isometric Application Load Balancer icon labeled 'web-alb' with a circular distribution symbol
- Blue curved arrows connect them showing HTTPS flow
ZONE 3 - Application Layer (light green tinted rectangle with dashed green border, labeled 'Private Subnet 10.0.2.0/24'):
- Three orange isometric EC2 server icons arranged in a clean row, each labeled 'web-1', 'web-2', 'web-3'
- The servers are grouped within a subtle dotted security boundary labeled 'web-sg'
- Purple curved arrows from the load balancer fan out to each server
ZONE 4 - Data Layer (light amber tinted rectangle with dashed amber border, labeled 'Database Subnet 10.0.3.0/24'):
- A blue isometric RDS database cylinder icon with a subtle glow, labeled 'PostgreSQL Primary'
- A smaller replica icon labeled 'Read Replica' below it
- Amber dashed curved arrows connect from the EC2 instances with pill-shaped labels reading 'PostgreSQL 5432'
FOOTER (inside the frame, at the bottom):
A thin footer bar inside the border frame contains a compact legend showing icon types with labels. The AWS logo appears discretely in the bottom-right corner, also inside the frame. Everything is well within the border with no content touching or extending beyond it.
The overall aesthetic is clean, modern, and visually stunning - suitable for executive presentations and technical documentation alike.
Microservices on Kubernetes:
A professional 16:9 landscape Kubernetes architecture diagram in a stunning modern infographic style.
CANVAS AND MARGINS:
The image has a generous white outer margin (at least 60 pixels on all sides) so no content approaches the page edges. Inside this margin, a subtle rounded-corner border with a thin charcoal stroke frames the entire diagram. All content is contained inside this border.
HEADER (inside the frame):
A gradient header bar spans the top inside the frame, transitioning from deep indigo on the left to violet on the right. The title 'Microservices on Kubernetes' appears in large, bold white sans-serif text. A subtitle reads 'EKS Production Cluster • Multi-Namespace Architecture' in smaller light purple text.
MAIN CANVAS:
Light cool gray background (#f8fafc). The diagram represents a Kubernetes cluster as a large rounded rectangle with a subtle shadow. Generous spacing between elements.
VISUAL STYLE:
All icons are clean isometric 3D with subtle shadows and modern gradient fills. The Kubernetes wheel logo appears subtly watermarked in the cluster background.
CLUSTER BOUNDARY:
A large rounded rectangle with a thin purple dashed border labeled 'EKS Cluster: k8s-prod' in the top-left corner.
INGRESS (top of cluster):
A purple isometric ingress controller icon labeled 'nginx-ingress' sits at the top center. A blue curved arrow enters from above, originating from a cloud/globe icon labeled 'Internet'.
NAMESPACE ZONES (arranged horizontally inside the cluster):
ZONE 1 - Frontend Namespace (light blue tinted rectangle with rounded corners):
- Header label: 'namespace: frontend'
- A purple Service icon labeled 'frontend-svc' at the top
- Three orange Pod icons in a row below, each labeled 'web-app'
- Pods connected to the service with thin lines
ZONE 2 - Backend Namespace (light green tinted rectangle):
- Header label: 'namespace: backend'
- A purple Service icon labeled 'api-svc'
- Three orange Pod icons labeled 'api-server'
- Two teal Pod icons labeled 'worker' below
- Internal green dotted arrows show async messaging
ZONE 3 - Data Namespace (light amber tinted rectangle):
- Header label: 'namespace: data'
- A blue isometric StatefulSet icon labeled 'postgres'
- A green PVC icon labeled 'db-storage' connected below
CONNECTIONS:
- Bright blue curved arrow with 'HTTPS 443' label from ingress to frontend service
- Purple curved arrows with 'HTTP 8080' labels from frontend pods to api-svc
- Amber dashed arrows with 'PostgreSQL 5432' labels from api pods to postgres
EXTERNAL SERVICES (outside cluster, right side):
- A green isometric S3 bucket icon labeled 'user-uploads'
- A blue RDS icon labeled 'analytics-db'
- Green dotted arrows connect worker pods to S3, amber dashed arrows connect api pods to RDS
FOOTER (inside the frame, at the bottom):
A compact footer bar inside the border frame shows a legend with icon samples and labels. Kubernetes logo on left, AWS logo on right - all inside the frame with no content touching the border edge.
The diagram is visually polished with consistent spacing, harmonious colors, generous margins, and professional aesthetics suitable for architecture review presentations.
Use this template as a starting point, filling in the bracketed sections:
A professional 16:9 landscape cloud architecture diagram in a stunning modern infographic style.
CANVAS AND MARGINS:
The image has a generous white outer margin (at least 60 pixels on all sides) so no content approaches the page edges. Inside this margin, a subtle rounded-corner border with a thin charcoal stroke frames all diagram content. Everything is contained inside this border with comfortable inner padding.
HEADER (inside the frame):
A gradient header bar spans the top inside the frame, transitioning from [PRIMARY_COLOR] on the left to [SECONDARY_COLOR] on the right. The title '[ARCHITECTURE_NAME]' appears in large, bold white sans-serif text. A subtitle reads '[DESCRIPTION] • [REGION/ENVIRONMENT]' in smaller light text.
MAIN CANVAS:
Light cool gray background (#f8fafc). Layout flows left-to-right showing the data/request path. Generous spacing between all elements.
VISUAL STYLE:
All icons are clean isometric 3D with subtle drop shadows and soft gradient fills - like high-end tech infographic illustrations. Consistent color palette: orange for compute, purple for networking, blue for databases, green for storage, teal for analytics.
ARCHITECTURE ZONES:
[Describe each zone with tinted background color, dashed border, label, and contained resources]
ZONE 1 - [ZONE_NAME] ([ZONE_COLOR] tinted rectangle with dashed border):
- [Resource descriptions with isometric style, color, and labels]
ZONE 2 - [ZONE_NAME] ([ZONE_COLOR] tinted rectangle):
- [Resource descriptions]
[Continue for additional zones...]
CONNECTIONS:
[Describe each connection with curved bezier arrows, color, and pill-shaped labels]
- [COLOR] curved arrow with '[PROTOCOL PORT]' label from [SOURCE] to [DESTINATION]
FOOTER (inside the frame, at the bottom):
A compact footer bar inside the border frame shows a legend with icon samples and labels. [PROVIDER] logo in bottom-right corner - all inside the frame with no content touching or extending beyond the border.
The diagram is visually polished with generous margins, consistent spacing, harmonious colors, and professional aesthetics.
Color suggestions for headers:
After creating the enhanced prompt, generate the diagram:
python ~/.claude/skills/nanobanana/scripts/generate.py "ENHANCED_PROMPT_HERE"
The script will save the diagram as a timestamped PNG file in the current directory.
After generating the diagram, provide the user with:
.tf, .tfvarsdepends_on) and implicit (resource references)Terraform Parsing Tiers (automatic selection):
| Parser | Accuracy | Requirements | What It Does |
|---|---|---|---|
| tfparse | Best | terraform init run, Python 3.10+ | Full expression evaluation, accurate dependencies |
| python-hcl2 | Good | None | Proper HCL2 syntax parsing, reference extraction |
| regex | Basic | None | Simple pattern matching, inferred dependencies |
The parser automatically selects the best available option:
.terraform/ exists and tfparse is installed → uses tfparseFor best results with Terraform:
cd /path/to/terraform
terraform init # Downloads providers, resolves modules
# Then run the diagram generator
.yaml, .yml, .json, .templateDependsOn, Ref, GetAtt referencesCloudFormation Parsing Tiers (automatic selection):
| Parser | Accuracy | Requirements | What It Does |
|---|---|---|---|
| cfn-lint | Best | pip install cfn-lint | Full intrinsic function parsing |
| PyYAML | Good | Built-in | Basic YAML with reference extraction |
The parser extracts dependencies from:
!Ref / Fn::Ref - Direct resource references!GetAtt / Fn::GetAtt - Attribute lookups!Sub / Fn::Sub - String substitution referencesDependsOn - Explicit dependenciesFn::If - Conditional branch scanning.yaml, .yml (manifests, Helm templates)Kubernetes Relationship Detection (inspired by KubeDiagrams):
| Relationship | Example | Detection Method |
|---|---|---|
| SELECTOR | Service → Deployment | Label selector matching |
| OWNER | Deployment → Pod | Implicit ownership hierarchy |
| REFERENCE | Ingress → Service | Backend service references |
| MOUNT | Deployment → ConfigMap | Volume mount definitions |
| COMMUNICATION | NetworkPolicy rules | Ingress/egress pod selectors |
Supported Kubernetes Resources (20+ types):
docker-compose.yaml, docker-compose.ymldepends_on, network membership, volume sharing.ts, .py, .gopip install pyyaml
For better Terraform parsing:
# Good: HCL2 parsing without terraform init
pip install python-hcl2
# Best: Full evaluation with terraform init (Python 3.10+ required)
pip install tfparse
For better CloudFormation parsing:
# Accurate intrinsic function parsing (!Ref, !GetAtt, !Sub)
pip install cfn-lint
# Gemini API key for Nano Banana Pro
export GEMINI_API_KEY="your-api-key-here"
Get your API key at: https://aistudio.google.com/apikey
For enhanced Terraform parsing:
pip install tfparse
For CloudFormation validation:
pip install cfn-lint
Nano Banana Pro generates raster images (PNG), not vector files. For editable SVG/PDF output, use a vectorization tool as a post-processing step:
Best Quality:
Free Options:
The parser handles:
All errors include clear messages for troubleshooting.
User Request: "Generate an architecture diagram from my Terraform code"
Steps:
.tf files in current directorypython ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform .python ~/.claude/skills/nanobanana/scripts/generate.py "PROMPT"User Request: "Show me what this CloudFormation template deploys"
Steps:
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py cloudformation template.yamlUser Request: "Diagram our Kubernetes application"
Steps:
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py kubernetes k8s/User Request: "Generate a diagram from https://github.com/example/terraform-aws-vpc"
Steps:
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform https://github.com/example/terraform-aws-vpcUser Request: "Show me the architecture in the /infrastructure folder of https://github.com/example/myapp"
Steps:
python ~/.claude/skills/iac-diagram-generator/scripts/parse_iac.py terraform https://github.com/example/myapp/tree/main/infrastructure