aws-diagrams
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAWS 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:
- Parse AWS Resources: Extract resources from CloudFormation, CLI output, or descriptions
- Map AWS Relationships: Identify VPCs, subnets, security groups, IAM roles
- Generate Eraser DSL: Create Eraser DSL code from AWS resources
- Call Eraser API: Use with
/api/render/elementsdiagramType: "cloud-architecture-diagram"
此技能通过解析AWS资源并直接调用Eraser API来生成AWS专属架构图:
- 解析AWS资源:从CloudFormation、CLI输出或文字描述中提取资源信息
- 映射AWS关系:识别VPC、子网、安全组、IAM角色等关联
- 生成Eraser DSL:根据AWS资源创建Eraser DSL代码
- 调用Eraser API:使用接口,指定
/api/render/elementsdiagramType: "cloud-architecture-diagram"
Instructions
使用说明
When the user provides AWS infrastructure information:
-
Parse the Source
- CloudFormation: Extract section, identify types (AWS::EC2::Instance, etc.)
Resources - CLI Output: Parse JSON output from commands
aws - Description: Identify AWS service names and relationships
- CloudFormation: Extract
-
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
-
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
-
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 - CRITICAL: Label Formatting Rules
-
Make the HTTP RequestIMPORTANT: You MUST execute this curl command after generating the DSL. Never stop after generating DSL without making the API call.CRITICAL: In theheader below, you MUST replace the value with your AI agent name:
X-Skill-Source- 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
bashcurl -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 }' - If you are Claude (Anthropic), use:
-
Track Sources During AnalysisAs 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., - VPC and subnet definitions)
infra/main.tf - 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
- Internal files: Record each file path you read and what information was extracted (e.g.,
-
Handle the ResponseCRITICAL: Minimal Output FormatYour response MUST always include these elements with clear headers:
-
Diagram Preview: Display with a header
## Diagram Use the ACTUALfrom the API response.imageUrl -
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. -
Sources section: Brief list of files/resources analyzed (if applicable)
## Sources - `path/to/file` - What was extracted -
Diagram Code section: The Eraser DSL in a code block withlanguage tag
eraser## Diagram Code ```eraser {DSL code here}undefined -
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基础设施信息时:
-
解析数据源
- CloudFormation:提取部分,识别资源类型(如AWS::EC2::Instance等)
Resources - CLI输出:解析命令返回的JSON输出
aws - 文字描述:识别AWS服务名称及相互关系
- CloudFormation:提取
-
识别AWS组件
- 网络类:VPC、子网、互联网网关、NAT网关、路由表
- 计算类:EC2实例、自动扩缩容组、Lambda函数、ECS服务
- 存储类:S3存储桶、EBS卷、EFS文件系统
- 数据库类:RDS实例、DynamoDB表、ElastiCache集群
- 安全类:安全组、IAM角色、IAM策略、网络访问控制列表(NACL)
- 负载均衡类:ALB、NLB、CLB
- 其他类:SQS队列、SNS主题、API网关、CloudFront
-
映射组件关系
- EC2实例所属子网
- 子网所属VPC
- 绑定到实例的安全组
- 绑定到服务的IAM角色
- 负载均衡器指向的实例
- 应用访问的数据库
-
生成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 - 关键:标签格式规则
-
发起HTTP请求重要提示:生成DSL后必须执行以下curl命令,绝对不能在生成DSL后停止操作而不调用API。关键:在下面的请求头中,必须将值替换为你的AI Agent名称:
X-Skill-Source- 如果你是Claude(Anthropic),使用:
claude - 如果你在Cursor中运行,使用:
cursor - 如果你是ChatGPT(OpenAI),使用:
chatgpt - 如果你是Gemini(Google),使用:
gemini - 其他情况,使用你的模型/Agent的小写名称
bashcurl -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 }' - 如果你是Claude(Anthropic),使用:
-
分析过程中跟踪数据源在分析文件和资源以生成架构图时,需跟踪:
- 内部文件:记录读取的每个文件路径及提取的信息(例如:- VPC和子网定义)
infra/main.tf - 外部参考:记录查阅的任何文档、示例或URL(例如:AWS VPC最佳实践文档)
- 注释:为每个数据源标注其对架构图的贡献
- 内部文件:记录读取的每个文件路径及提取的信息(例如:
-
处理API响应关键:最小输出格式你的响应必须始终包含以下元素,并带有清晰的标题:
-
架构图预览:带标题展示
## 架构图 使用API响应中的实际。imageUrl -
编辑器链接:带标题展示
## 在Eraser中打开 [在Eraser编辑器中编辑此架构图]({createEraserFileUrl})使用API响应中的实际URL。 -
数据源部分:简要列出分析的文件/资源(如有)
## 数据源 - `path/to/file` - 提取的信息内容 -
架构图代码部分:将Eraser DSL放在带有语言标签的代码块中
eraser## 架构图代码 ```eraser {DSL code here}undefined -
了解更多链接:
你可以访问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.microyaml
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.microExpected Behavior
预期行为
-
Parses CloudFormation:
- Networking: VPC, Subnet
- Compute: EC2 instance, Lambda function
- Storage: S3 bucket
- Database: RDS PostgreSQL instance
-
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 -> MyDatabaseImportant: 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. -
Callswith
/api/render/elementsdiagramType: "cloud-architecture-diagram"
-
解析CloudFormation模板:
- 网络类:VPC、子网
- 计算类:EC2实例、Lambda函数
- 存储类:S3存储桶
- 数据库类:RDS PostgreSQL实例
-
生成展示多种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分组。 -
调用接口,指定
/api/render/elementsdiagramType: "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
预期行为
-
Parses JSON to extract:
- Instance IDs, types, states
- Subnet IDs, VPC IDs
- Security groups
- Tags
-
Formats and calls API
-
解析JSON提取以下信息:
- 实例ID、类型、状态
- 子网ID、VPC ID
- 安全组
- 标签
-
格式化信息并调用API