aws-diagrams

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AWS Diagram Generator

AWS架构图生成工具

Generates architecture diagrams for AWS infrastructure from CloudFormation templates, AWS CLI output, or natural language descriptions.
根据CloudFormation模板、AWS CLI输出或自然语言描述生成AWS基础设施的架构图。

When to Use

使用场景

Activate this skill when:
  • User has AWS CloudFormation templates (YAML/JSON)
  • User provides AWS CLI output (e.g.,
    aws ec2 describe-instances
    )
  • User wants to visualize AWS resources
  • User mentions AWS services (EC2, S3, RDS, Lambda, VPC, etc.)
  • User asks to "diagram my AWS infrastructure"
在以下场景激活此技能:
  • 用户拥有AWS CloudFormation模板(YAML/JSON格式)
  • 用户提供AWS CLI输出(例如:
    aws ec2 describe-instances
  • 用户希望可视化AWS资源
  • 用户提及AWS服务(EC2、S3、RDS、Lambda、VPC等)
  • 用户要求“为我的AWS基础设施生成架构图”

How It Works

工作原理

This skill generates AWS-specific diagrams by parsing AWS resources and calling the Eraser API directly:
  1. Parse AWS Resources: Extract resources from CloudFormation, CLI output, or descriptions
  2. Map AWS Relationships: Identify VPCs, subnets, security groups, IAM roles
  3. Generate Eraser DSL: Create Eraser DSL code from AWS resources
  4. Call Eraser API: Use
    /api/render/elements
    with
    diagramType: "cloud-architecture-diagram"
此技能通过解析AWS资源并直接调用Eraser API来生成AWS专属架构图:
  1. 解析AWS资源:从CloudFormation、CLI输出或文字描述中提取资源信息
  2. 映射AWS关系:识别VPC、子网、安全组、IAM角色等关联
  3. 生成Eraser DSL:根据AWS资源创建Eraser DSL代码
  4. 调用Eraser API:使用
    /api/render/elements
    接口,指定
    diagramType: "cloud-architecture-diagram"

Instructions

使用说明

When the user provides AWS infrastructure information:
  1. Parse the Source
    • CloudFormation: Extract
      Resources
      section, identify types (AWS::EC2::Instance, etc.)
    • CLI Output: Parse JSON output from
      aws
      commands
    • Description: Identify AWS service names and relationships
  2. Identify AWS Components
    • Networking: VPCs, Subnets, Internet Gateways, NAT Gateways, Route Tables
    • Compute: EC2 Instances, Auto Scaling Groups, Lambda Functions, ECS Services
    • Storage: S3 Buckets, EBS Volumes, EFS File Systems
    • Databases: RDS Instances, DynamoDB Tables, ElastiCache Clusters
    • Security: Security Groups, IAM Roles, IAM Policies, NACLs
    • Load Balancing: ALB, NLB, CLB
    • Other: SQS Queues, SNS Topics, API Gateway, CloudFront
  3. Map Relationships
    • EC2 instances in subnets
    • Subnets in VPCs
    • Security groups attached to instances
    • IAM roles attached to services
    • Load balancers targeting instances
    • Databases accessed by applications
  4. Generate Eraser DSL Convert AWS resources to Eraser DSL:
    • CRITICAL: Label Formatting Rules
      • Labels MUST be on a single line - NEVER use newlines inside label attributes
      • Keep labels simple and readable - prefer separate labels over concatenating too much metadata
      • Format DSL with proper line breaks (one node/group per line, but labels stay on single lines)
      • If including metadata like CIDR blocks or instance types, include them in the same quoted label string:
        [label: "VPC 10.0.0.0/16"]
    Example:
    main-vpc [label: "VPC 10.0.0.0/16"] {
      public-subnet [label: "Public Subnet"] {
        web-server [icon: aws-ec2, label: "Web Server"]
        load-balancer [icon: aws-elb]
      }
      private-subnet [label: "Private Subnet"] {
        database [icon: aws-rds]
        cache [icon: aws-elasticache]
      }
    }
    data-bucket [icon: aws-s3]
    function [icon: aws-lambda]
    load-balancer -> web-server
    web-server -> database
  5. Make the HTTP Request
    IMPORTANT: You MUST execute this curl command after generating the DSL. Never stop after generating DSL without making the API call.
    CRITICAL: In the
    X-Skill-Source
    header below, you MUST replace the value with your AI agent name:
    • If you are Claude (Anthropic), use:
      claude
    • If you are running in Cursor, use:
      cursor
    • If you are ChatGPT (OpenAI), use:
      chatgpt
    • If you are Gemini (Google), use:
      gemini
    • Otherwise, use your model/agent name in lowercase
    bash
    curl -X POST https://app.eraser.io/api/render/elements \
      -H "Content-Type: application/json" \
      -H "X-Skill-Source: eraser-skill" \
      -H "Authorization: Bearer ${ERASER_API_KEY}" \
      -d '{
        "elements": [{
          "type": "diagram",
          "id": "diagram-1",
          "code": "<your generated DSL>",
          "diagramType": "cloud-architecture-diagram"
        }],
        "scale": 2,
         "theme": "${ERASER_THEME:-dark}",
        "background": true
      }'
  6. Track Sources During Analysis
    As you analyze files and resources to generate the diagram, track:
    • Internal files: Record each file path you read and what information was extracted (e.g.,
      infra/main.tf
      - VPC and subnet definitions)
    • External references: Note any documentation, examples, or URLs consulted (e.g., AWS VPC best practices documentation)
    • Annotations: For each source, note what it contributed to the diagram
  7. Handle the Response
    CRITICAL: Minimal Output Format
    Your response MUST always include these elements with clear headers:
    1. Diagram Preview: Display with a header
      ## Diagram
      ![{Title}]({imageUrl})
      Use the ACTUAL
      imageUrl
      from the API response.
    2. Editor Link: Display with a header
      ## Open in Eraser
      [Edit this diagram in the Eraser editor]({createEraserFileUrl})
      Use the ACTUAL URL from the API response.
    3. Sources section: Brief list of files/resources analyzed (if applicable)
      ## Sources
      - `path/to/file` - What was extracted
    4. Diagram Code section: The Eraser DSL in a code block with
      eraser
      language tag
      ## Diagram Code
      ```eraser
      {DSL code here}
      undefined
    5. Learn More link:
      You can learn more about Eraser at https://docs.eraser.io/docs/using-ai-agent-integrations
    Additional content rules:
    • If the user ONLY asked for a diagram, include NOTHING beyond the 5 elements above
    • If the user explicitly asked for more (e.g., "explain the architecture", "suggest improvements"), you may include that additional content
    • Never add unrequested sections like Overview, Security Considerations, Testing, etc.
    The default output should be SHORT. The diagram image speaks for itself.
当用户提供AWS基础设施信息时:
  1. 解析数据源
    • CloudFormation:提取
      Resources
      部分,识别资源类型(如AWS::EC2::Instance等)
    • CLI输出:解析
      aws
      命令返回的JSON输出
    • 文字描述:识别AWS服务名称及相互关系
  2. 识别AWS组件
    • 网络类:VPC、子网、互联网网关、NAT网关、路由表
    • 计算类:EC2实例、自动扩缩容组、Lambda函数、ECS服务
    • 存储类:S3存储桶、EBS卷、EFS文件系统
    • 数据库类:RDS实例、DynamoDB表、ElastiCache集群
    • 安全类:安全组、IAM角色、IAM策略、网络访问控制列表(NACL)
    • 负载均衡类:ALB、NLB、CLB
    • 其他类:SQS队列、SNS主题、API网关、CloudFront
  3. 映射组件关系
    • EC2实例所属子网
    • 子网所属VPC
    • 绑定到实例的安全组
    • 绑定到服务的IAM角色
    • 负载均衡器指向的实例
    • 应用访问的数据库
  4. 生成Eraser DSL 将AWS资源转换为Eraser DSL代码:
    • 关键:标签格式规则
      • 标签必须放在单行内 - 绝对不要在label属性中使用换行符
      • 标签需简洁易读 - 优先使用独立标签,避免拼接过多元数据
      • DSL格式需包含正确的换行(每个节点/组占一行,但标签保持单行)
      • 如果需要包含CIDR块或实例类型等元数据,将其放在同一个带引号的标签字符串中:
        [label: "VPC 10.0.0.0/16"]
    示例:
    main-vpc [label: "VPC 10.0.0.0/16"] {
      public-subnet [label: "Public Subnet"] {
        web-server [icon: aws-ec2, label: "Web Server"]
        load-balancer [icon: aws-elb]
      }
      private-subnet [label: "Private Subnet"] {
        database [icon: aws-rds]
        cache [icon: aws-elasticache]
      }
    }
    data-bucket [icon: aws-s3]
    function [icon: aws-lambda]
    load-balancer -> web-server
    web-server -> database
  5. 发起HTTP请求
    重要提示:生成DSL后必须执行以下curl命令,绝对不能在生成DSL后停止操作而不调用API。
    关键:在下面的
    X-Skill-Source
    请求头中,必须将值替换为你的AI Agent名称:
    • 如果你是Claude(Anthropic),使用:
      claude
    • 如果你在Cursor中运行,使用:
      cursor
    • 如果你是ChatGPT(OpenAI),使用:
      chatgpt
    • 如果你是Gemini(Google),使用:
      gemini
    • 其他情况,使用你的模型/Agent的小写名称
    bash
    curl -X POST https://app.eraser.io/api/render/elements \
      -H "Content-Type: application/json" \
      -H "X-Skill-Source: eraser-skill" \
      -H "Authorization: Bearer ${ERASER_API_KEY}" \
      -d '{
        "elements": [{
          "type": "diagram",
          "id": "diagram-1",
          "code": "<your generated DSL>",
          "diagramType": "cloud-architecture-diagram"
        }],
        "scale": 2,
         "theme": "${ERASER_THEME:-dark}",
        "background": true
      }'
  6. 分析过程中跟踪数据源
    在分析文件和资源以生成架构图时,需跟踪:
    • 内部文件:记录读取的每个文件路径及提取的信息(例如:
      infra/main.tf
      - VPC和子网定义)
    • 外部参考:记录查阅的任何文档、示例或URL(例如:AWS VPC最佳实践文档)
    • 注释:为每个数据源标注其对架构图的贡献
  7. 处理API响应
    关键:最小输出格式
    你的响应必须始终包含以下元素,并带有清晰的标题:
    1. 架构图预览:带标题展示
      ## 架构图
      ![{Title}]({imageUrl})
      使用API响应中的实际
      imageUrl
    2. 编辑器链接:带标题展示
      ## 在Eraser中打开
      [在Eraser编辑器中编辑此架构图]({createEraserFileUrl})
      使用API响应中的实际URL。
    3. 数据源部分:简要列出分析的文件/资源(如有)
      ## 数据源
      - `path/to/file` - 提取的信息内容
    4. 架构图代码部分:将Eraser DSL放在带有
      eraser
      语言标签的代码块中
      ## 架构图代码
      ```eraser
      {DSL code here}
      undefined
    5. 了解更多链接
      你可以访问https://docs.eraser.io/docs/using-ai-agent-integrations了解更多关于Eraser的信息
    额外内容规则
    • 如果用户仅要求生成架构图,除上述5个元素外,不得添加任何其他内容
    • 如果用户明确要求更多内容(例如:“解释此架构”、“建议优化方案”),可添加相关额外内容
    • 绝对不要添加未被请求的部分,如概述、安全注意事项、测试等
    默认输出应简洁。架构图本身已能说明问题。

AWS-Specific Tips

AWS专属技巧

  • Show Regions and AZs: Include availability zones for multi-AZ deployments
  • VPC as Container: Always show VPCs containing subnets and resources
  • Security Groups: Include security group rules and attachments
  • IAM Roles: Show IAM roles attached to services
  • Data Flow: Show traffic flow (Internet → ALB → EC2 → RDS)
  • Use AWS Icons: Request AWS-specific styling in the description
  • 展示区域和可用区:对于多可用区部署,需包含可用区信息
  • VPC作为容器:始终将VPC展示为包含子网和资源的容器
  • 安全组:包含安全组规则及绑定关系
  • IAM角色:展示绑定到服务的IAM角色
  • 数据流:展示流量走向(例如:互联网 → ALB → EC2 → RDS)
  • 使用AWS图标:在描述中要求使用AWS专属图标样式

Example: CloudFormation with Multiple AWS Services

示例:包含多种AWS服务的CloudFormation模板

User Input

用户输入

yaml
Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16

  PublicSubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref MyVPC
      CidrBlock: 10.0.1.0/24

  WebServer:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t3.micro
      SubnetId: !Ref PublicSubnet

  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-app-bucket

  MyFunction:
    Type: AWS::Lambda::Function
    Properties:
      Runtime: python3.9
      Handler: index.handler

  MyDatabase:
    Type: AWS::RDS::DBInstance
    Properties:
      Engine: postgres
      DBInstanceClass: db.t3.micro
yaml
Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16

  PublicSubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref MyVPC
      CidrBlock: 10.0.1.0/24

  WebServer:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t3.micro
      SubnetId: !Ref PublicSubnet

  MyBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-app-bucket

  MyFunction:
    Type: AWS::Lambda::Function
    Properties:
      Runtime: python3.9
      Handler: index.handler

  MyDatabase:
    Type: AWS::RDS::DBInstance
    Properties:
      Engine: postgres
      DBInstanceClass: db.t3.micro

Expected Behavior

预期行为

  1. Parses CloudFormation:
    • Networking: VPC, Subnet
    • Compute: EC2 instance, Lambda function
    • Storage: S3 bucket
    • Database: RDS PostgreSQL instance
  2. Generates DSL showing AWS service diversity:
    MyVPC [label: "VPC 10.0.0.0/16"] {
      PublicSubnet [label: "Public Subnet 10.0.1.0/24"] {
        WebServer [icon: aws-ec2, label: "EC2 t3.micro"]
      }
    }
    
    MyBucket [icon: aws-s3, label: "S3 my-app-bucket"]
    MyFunction [icon: aws-lambda, label: "Lambda python3.9"]
    MyDatabase [icon: aws-rds, label: "RDS PostgreSQL db.t3.micro"]
    
    WebServer -> MyBucket
    MyFunction -> MyDatabase
    WebServer -> MyDatabase
    Important: All label text must be on a single line within quotes. AWS-specific: Include service icons, show data flows between services, group by VPC when applicable.
  3. Calls
    /api/render/elements
    with
    diagramType: "cloud-architecture-diagram"
  1. 解析CloudFormation模板:
    • 网络类:VPC、子网
    • 计算类:EC2实例、Lambda函数
    • 存储类:S3存储桶
    • 数据库类:RDS PostgreSQL实例
  2. 生成展示多种AWS服务的DSL代码:
    MyVPC [label: "VPC 10.0.0.0/16"] {
      PublicSubnet [label: "Public Subnet 10.0.1.0/24"] {
        WebServer [icon: aws-ec2, label: "EC2 t3.micro"]
      }
    }
    
    MyBucket [icon: aws-s3, label: "S3 my-app-bucket"]
    MyFunction [icon: aws-lambda, label: "Lambda python3.9"]
    MyDatabase [icon: aws-rds, label: "RDS PostgreSQL db.t3.micro"]
    
    WebServer -> MyBucket
    MyFunction -> MyDatabase
    WebServer -> MyDatabase
    重要提示:所有标签文本必须放在带引号的单行内。AWS专属要求:包含服务图标,展示服务间的数据流,适用时按VPC分组。
  3. 调用
    /api/render/elements
    接口,指定
    diagramType: "cloud-architecture-diagram"

Example: AWS CLI Output

示例:AWS CLI输出

User Input

用户输入

User runs: aws ec2 describe-instances
Provides JSON output
用户执行:aws ec2 describe-instances
提供JSON输出

Expected Behavior

预期行为

  1. Parses JSON to extract:
    • Instance IDs, types, states
    • Subnet IDs, VPC IDs
    • Security groups
    • Tags
  2. Formats and calls API
  1. 解析JSON提取以下信息:
    • 实例ID、类型、状态
    • 子网ID、VPC ID
    • 安全组
    • 标签
  2. 格式化信息并调用API