Discover AWS infrastructure and generate architecture diagrams using AI

version
1.0.0
GitHub stars
14

Install

/plugin install aws-diagrams@claude-cloud-diagrams

Run it inside Claude Code after adding the marketplace with /plugin marketplace add mpuig/claude-cloud-diagrams.

Contents

Discovered from source

Skills 2

AWS Diagram Generator

Generate architecture diagrams from aws_infrastructure.json using the Python diagrams library.

Before Starting

  1. Check that aws_infrastructure.json exists in the current directory

  2. Ask user which diagram type they want:

    • architecture - Overall infrastructure overview
    • security - Security controls and traffic flow
    • network - Network topology and connectivity
    • data-flow - Data flow between components
    • all - Generate all types
  3. Ask for output format: png (default), svg, or pdf

Process

  1. Read aws_infrastructure.json
  2. Generate Python code using the diagrams library
  3. Write the code to a temporary file
  4. Execute it with python <file>.py
  5. Report the generated files to the user

Diagrams Library Reference

Basic Structure

from diagrams import Diagram, Cluster, Edge

with Diagram("Title", filename="output_name", outformat="png", show=False):
    # Create nodes and connections

AWS Icons (import from diagrams.aws.*)

Compute:

from diagrams.aws.compute import ECS, Lambda, Fargate, EC2, EKS, Batch, ECR

Database:

from diagrams.aws.database import RDS, Aurora, ElastiCache, Dynamodb, DocumentDB, Neptune, Redshift

Note: Use Dynamodb (not DynamoDB)

Network:

from diagrams.aws.network import ALB, NLB, CloudFront, Route53, VPC, InternetGateway, NATGateway, TransitGateway, Endpoint, APIGateway

Storage:

from diagrams.aws.storage import S3, EFS

Security:

from diagrams.aws.security import WAF, Shield, ACM, Cognito, SecretsManager, KMS, IAM

Integration:

from diagrams.aws.integration import SQS, SNS, Eventbridge, StepFunctions

Note: Use Eventbridge (not EventBridge)

Analytics:

from diagrams.aws.analytics import Kinesis, Athena, Glue, EMR, Quicksight

Management:

from diagrams.aws.management import Cloudwatch, CloudwatchAlarm, Cloudtrail

General (for unknown services):

from diagrams.aws.general import General

External/Users:

from diagrams.onprem.network import Internet
from diagrams.onprem.client import Users

Connections

# Left to right flow
node1 >> node2
node1 >> Edge(label="HTTPS") >> node2

# Multiple targets
node1 >> [node2, node3]

Clusters (for grouping)

with Cluster("VPC"):
    with Cluster("Public Subnet"):
        alb = ALB("Load Balancer")
    with Cluster("Private Subnet"):
        app = Fargate("App")

Diagram Types

Architecture Diagram

Show overall infrastructure:

  • Internet/Users connecting to load balancers
  • Load balancers to compute (ECS, Lambda, EC2)
  • Compute to databases (RDS, DynamoDB, ElastiCache)
  • Storage services (S3)
  • Group by VPC and subnet types

Security Diagram

Show security controls:

  • WAF protecting load balancers
  • Cognito for authentication
  • ACM certificates
  • Security boundaries (VPC, subnets)
  • Traffic flow from external to internal
  • KMS, Secrets Manager

Network Diagram

Show network topology:

  • VPC with CIDR
  • Subnets grouped by availability zone
  • Internet Gateway and NAT Gateways
  • Transit Gateway connections
  • VPC Endpoints

Data Flow Diagram

Show data movement:

  • How data enters (API, events)
  • Processing pipeline (compute services)
  • Data storage destinations
  • Caching layers
  • Event flows (SQS, SNS, EventBridge)

Output Files

Use these filenames:

  • aws_architecture.png
  • aws_security.png
  • aws_network.png
  • aws_data_flow.png

Guidelines

  1. Set show=False in Diagram constructor
  2. Create meaningful labels from the JSON data
  3. Draw connections based on logical relationships
  4. Use Clusters to group related resources
  5. Limit displayed items to 3-5 per category for readability
  6. For services not in the library, use General
  7. Always use the exact import names (case-sensitive)

Example Generated Code

from diagrams import Diagram, Cluster
from diagrams.aws.compute import Fargate
from diagrams.aws.database import RDS, ElastiCache
from diagrams.aws.network import ALB, InternetGateway
from diagrams.aws.storage import S3
from diagrams.onprem.network import Internet

with Diagram("AWS Architecture - MyProject (PROD)", filename="aws_architecture", outformat="png", show=False):
    internet = Internet("Users")

    with Cluster("VPC: 10.0.0.0/16"):
        igw = InternetGateway("IGW")

        with Cluster("Public Subnet"):
            alb = ALB("Public ALB")

        with Cluster("Private Subnet"):
            with Cluster("ECS Cluster"):
                svc1 = Fargate("api")
                svc2 = Fargate("worker")

            db = RDS("Aurora")
            cache = ElastiCache("Redis")

    s3 = S3("Assets")

    internet >> igw >> alb >> [svc1, svc2]
    svc1 >> [db, cache, s3]
    svc2 >> [db, s3]

After Generation

Tell the user:

  1. Which diagram files were created
  2. They can open PNG/SVG directly or import into documentation

AWS Infrastructure Discovery

Explore an AWS account and collect comprehensive information about its infrastructure.

Before Starting

Ask the user for:

  1. AWS Profile - Which AWS profile to use (or use default)
  2. AWS Region - Which region to scan (or use default)

AWS CLI Configuration

Use the profile and region flags with all AWS CLI commands:

aws <command> --profile <profile> --region <region>

Discovery Process

Explore systematically. Start with basics, then dig deeper based on what you find.

1. Account Identity

aws sts get-caller-identity --profile <profile> --region <region>

2. Networking

  • VPCs: aws ec2 describe-vpcs
  • Subnets: aws ec2 describe-subnets
  • Internet Gateways: aws ec2 describe-internet-gateways
  • NAT Gateways: aws ec2 describe-nat-gateways
  • Transit Gateways: aws ec2 describe-transit-gateways
  • VPC Endpoints: aws ec2 describe-vpc-endpoints
  • Route Tables: aws ec2 describe-route-tables

3. Compute

  • ECS Clusters: aws ecs list-clusters then aws ecs describe-clusters
  • ECS Services: aws ecs list-services --cluster <name> then aws ecs describe-services
  • Lambda: aws lambda list-functions
  • EC2: aws ec2 describe-instances
  • EKS: aws eks list-clusters

4. Load Balancing

  • ALB/NLB: aws elbv2 describe-load-balancers
  • Listeners: aws elbv2 describe-listeners --load-balancer-arn <arn>
  • Target Groups: aws elbv2 describe-target-groups
  • Rules: aws elbv2 describe-rules --listener-arn <arn>

5. Databases

  • RDS: aws rds describe-db-instances
  • Aurora: aws rds describe-db-clusters
  • DynamoDB: aws dynamodb list-tables
  • ElastiCache: aws elasticache describe-cache-clusters

6. Storage

  • S3: aws s3api list-buckets
  • EFS: aws efs describe-file-systems
  • ECR: aws ecr describe-repositories

7. Security

  • Security Groups: aws ec2 describe-security-groups
  • WAF: aws wafv2 list-web-acls --scope REGIONAL
  • Cognito: aws cognito-idp list-user-pools --max-results 20
  • ACM: aws acm list-certificates
  • Secrets Manager: aws secretsmanager list-secrets
  • KMS: aws kms list-keys

8. Messaging

  • SQS: aws sqs list-queues
  • SNS: aws sns list-topics
  • EventBridge: aws events list-rules

9. API & CDN

  • API Gateway: aws apigateway get-rest-apis
  • CloudFront: aws cloudfront list-distributions

Output Format

Create aws_infrastructure.json with this structure:

{
  "metadata": {
    "account_id": "...",
    "region": "...",
    "environment": "...",
    "project": "...",
    "discovered_at": "..."
  },
  "networking": {
    "vpc": {"id": "...", "name": "...", "cidr": "..."},
    "subnets": {
      "public": [{"id": "...", "name": "...", "cidr": "...", "az": "..."}],
      "private": [{"id": "...", "name": "...", "cidr": "...", "az": "..."}]
    },
    "internet_gateway": {"id": "..."},
    "nat_gateways": [...],
    "transit_gateway": {"id": "...", "routes": [...]},
    "vpc_endpoints": [{"id": "...", "type": "...", "service": "..."}]
  },
  "load_balancers": {
    "public": {"name": "...", "scheme": "internet-facing", "dns_name": "..."},
    "private": {"name": "...", "scheme": "internal"}
  },
  "compute": {
    "ecs_cluster": {"name": "..."},
    "ecs_services": [{"name": "...", "launch_type": "FARGATE"}],
    "lambda_functions": [{"name": "...", "runtime": "..."}],
    "ec2_instances": [...]
  },
  "databases": {
    "aurora_clusters": [{"database_name": "...", "engine": "..."}],
    "dynamodb_tables": [{"name": "..."}],
    "elasticache": {"engine": "redis", "num_cache_clusters": 2}
  },
  "storage": {
    "s3_buckets": [{"name": "..."}],
    "ecr_repositories": [...]
  },
  "security": {
    "waf": {"web_acl": {"name": "..."}},
    "acm_certificates": [{"domain": "..."}],
    "cognito_pools": [{"name": "..."}]
  },
  "messaging": {
    "sqs_queues": [...],
    "sns_topics": [...],
    "eventbridge_rules": [...]
  },
  "traffic_rules": {
    "allowed_sources": {
      "public_internet": {"cidrs": ["0.0.0.0/0"], "ports": [443]},
      "corporate": {"cidrs": ["10.0.0.0/8"], "ports": [80, 443]}
    },
    "domains": {
      "public": ["api.example.com"],
      "private": ["internal.example.com"]
    }
  }
}

Guidelines

  • Only include sections that have resources (omit empty sections)
  • Infer environment and project from resource names/tags
  • Infer traffic rules from security group ingress rules and load balancer configurations
  • For subnets, use "az" field (not "availability_zone")
  • Skip empty services quickly - if list-* returns empty, move on
  • Add new sections for services not listed (e.g., "step_functions", "glue", "opensearch")

After Discovery

Tell the user:

  1. What was discovered (summary of resources)
  2. That they can now generate diagrams with: "generate AWS diagram"

Sponsors

Details

Marketplace
mpuig/claude-cloud-diagrams
Author
mpuig
Category
Community
License
MIT
Keywords
aws, infrastructure, diagrams, architecture