aws-architecture-diagram
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAWS Architecture Diagram Skill
AWS架构图绘制技能
Generate AWS architecture diagrams as native files using official AWS Architecture Icons. Optionally export to PNG, SVG, or PDF with embedded XML (so exported files remain editable in draw.io).
.drawio使用官方AWS架构图标生成原生 格式的AWS架构图。可选导出为嵌入XML的PNG、SVG或PDF格式(导出后的文件可在draw.io中继续编辑)。
.drawioHow to create a diagram
如何创建图表
- Generate draw.io XML in mxGraphModel format following the rules below
- Write the XML to a file using the Write tool
.drawio - If the user requested an export format (png, svg, pdf), export using the draw.io CLI (see Export section)
- Open the result with (macOS),
open(Linux), or print the pathxdg-open
- 生成draw.io XML:遵循以下规则,生成mxGraphModel格式的XML
- 写入XML到文件:使用写入工具将XML保存为 文件
.drawio - 若用户要求导出格式(png、svg、pdf),使用draw.io CLI进行导出(见导出章节)
- 打开结果:在macOS使用,Linux使用
open,或直接输出文件路径xdg-open
Layout Rules
布局规则
- Left-to-right flow for data/request path
- UI/Frontend on the LEFT (users access from left side)
- Data sources / external systems on the RIGHT
- Use horizontal lanes for parallel paths (top lane, bottom lane)
- Minimum 220px horizontal spacing between icons (room for edge labels)
- Minimum 250px vertical spacing between lanes
- Secondary/auxiliary services (monitoring, DLQ) go BELOW main flow with 280px+ gap
- Canvas: , viewport
pageWidth="2400" pageHeight="1400"dx="2800" dy="1600" - Always include a title block after the background rectangle:
xml
<mxCell value="<b>Diagram Title</b><br>Author | Date | Version" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=14;spacing=8;" vertex="1" parent="1">
<mxGeometry x="40" y="30" width="420" height="60" as="geometry" />
</mxCell>- 数据/请求路径采用从左到右的流向
- UI/前端放置在左侧(用户从左侧访问)
- 数据源/外部系统放置在右侧
- 使用水平分栏表示并行路径(上方栏、下方栏)
- 图标间最小水平间距为220px(预留边缘标签空间)
- 分栏间最小垂直间距为250px
- 次要/辅助服务(监控、死信队列DLQ)放置在主流程下方,间距需≥280px
- 画布设置:,视口
pageWidth="2400" pageHeight="1400"dx="2800" dy="1600" - 背景矩形后必须包含标题块:
xml
<mxCell value="<b>Diagram Title</b><br>Author | Date | Version" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=14;spacing=8;" vertex="1" parent="1">
<mxGeometry x="40" y="30" width="420" height="60" as="geometry" />
</mxCell>Icon Style
图标样式
- Icons are from draw.io's built-in stencil library — the official AWS Architecture Icons (https://aws.amazon.com/architecture/icons/)
mxgraph.aws4 - Icon size: 78x78px for main services, 65x65px for secondary
- Use on all icons
sketch=0 - Use on all AWS service icons
strokeColor=#ffffff - Font size: 12px for labels
- NO colored backgrounds on group boxes — always
fillColor=none
- 图标来自draw.io内置的模板库——官方AWS架构图标(https://aws.amazon.com/architecture/icons/)
mxgraph.aws4 - 图标尺寸:主服务为78x78px,次要服务为65x65px
- 所有图标均设置
sketch=0 - 所有AWS服务图标设置
strokeColor=#ffffff - 标签字体大小:12px
- 分组框禁止使用彩色背景——始终设置
fillColor=none
Edge Style — CRITICAL FOR CLEAN DIAGRAMS
边缘样式——对整洁图表至关重要
Base edge style:
edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;Edge label rules:
- Keep labels SHORT (1-2 words max). Detail goes in icon labels, not edge labels.
- Always add to edges with labels
labelBackgroundColor=#F5F5F5;fontSize=11; - For edges WITHOUT labels: omit entirely
value - When NOT to label: if the flow is obvious (Lambda → DynamoDB doesn't need "Write")
For edges to services ABOVE or BELOW main flow, use explicit exit/entry points:
- Exit bottom:
exitX=0.5;exitY=1;exitDx=0;exitDy=0; - Enter top:
entryX=0.5;entryY=0;entryDx=0;entryDy=0; - This prevents draw.io from routing lines through other icons
Edge types:
- Solid (): primary data flow
strokeWidth=2 - Dashed (): optional/async
strokeWidth=2;dashed=1; - Red dashed (): error path
strokeWidth=2;dashed=1;strokeColor=#DD344C;
Edge attachment (CRITICAL — fixes "green cross" problem):
- Every edge MUST have both and
source="<cell-id>"attributes referencing valid cell IDstarget="<cell-id>" - NEVER create floating/unattached edges — all edges must be bound to shapes at both ends
- Always include and
exitX/exitYto define exact connection points on the shape perimeterentryX/entryY - Cross-container edges: When source and target are in different containers, set the edge's
parent="1"
基础边缘样式:
edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;边缘标签规则:
- 标签保持简短(最多1-2个词),详细信息放在图标标签中,而非边缘标签
- 带标签的边缘需添加
labelBackgroundColor=#F5F5F5;fontSize=11; - 无标签的边缘:完全省略属性
value - 无需添加标签的场景:流向明显时(如Lambda → DynamoDB不需要标注“写入”)
连接主流程上方或下方服务的边缘,需使用明确的出入口点:
- 从底部流出:
exitX=0.5;exitY=1;exitDx=0;exitDy=0; - 从顶部流入:
entryX=0.5;entryY=0;entryDx=0;entryDy=0; - 此设置可避免draw.io将线条穿过其他图标
边缘类型:
- 实线():主要数据流
strokeWidth=2 - 虚线():可选/异步流程
strokeWidth=2;dashed=1; - 红色虚线():错误路径
strokeWidth=2;dashed=1;strokeColor=#DD344C;
边缘附着(至关重要——解决“绿色十字”问题):
- 每条边缘必须包含和
source="<cell-id>"属性,引用有效的单元格IDtarget="<cell-id>" - 禁止创建浮动/未附着的边缘——所有边缘两端必须绑定到形状
- 始终包含和
exitX/exitY定义形状边缘的精确连接点entryX/entryY - 跨容器边缘:当源和目标位于不同容器中时,将边缘的
parent="1"
PNG Export Background
PNG导出背景
First element after root cells (lowest z-order):
xml
<mxCell value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="0" y="0" width="2400" height="1400" as="geometry" />
</mxCell>根单元格后的第一个元素(最低层级):
xml
<mxCell value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="0" y="0" width="2400" height="1400" as="geometry" />
</mxCell>AWS Icon Patterns (VERIFIED WORKING)
AWS图标模式(已验证可用)
resourceIcon (78x78, colored square frame)
resourceIcon(78x78,带彩色方形边框)
| Service | resIcon | fillColor |
|---|---|---|
| Lambda | | |
| API Gateway | | |
| EventBridge | | |
| SNS | | |
| SES | | |
| Step Functions | | |
| DynamoDB | | |
| RDS | | |
| S3 | | |
| CloudFront | | |
| Route 53 | | |
| ECS | | |
| EC2 | | |
Style template:
sketch=0;points=[[0,0,0],[0.25,0,0],[0.5,0,0],[0.75,0,0],[1,0,0],[0,1,0],[0.25,1,0],[0.5,1,0],[0.75,1,0],[1,1,0],[0,0.25,0],[0,0.5,0],[0,0.75,0],[1,0.25,0],[1,0.5,0],[1,0.75,0]];outlineConnect=0;fontColor=#232F3E;fillColor=<COLOR>;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.<SERVICE>| 服务 | resIcon | fillColor |
|---|---|---|
| Lambda | | |
| API Gateway | | |
| EventBridge | | |
| SNS | | |
| SES | | |
| Step Functions | | |
| DynamoDB | | |
| RDS | | |
| S3 | | |
| CloudFront | | |
| Route 53 | | |
| ECS | | |
| EC2 | | |
样式模板:
sketch=0;points=[[0,0,0],[0.25,0,0],[0.5,0,0],[0.75,0,0],[1,0,0],[0,1,0],[0.25,1,0],[0.5,1,0],[0.75,1,0],[1,1,0],[0,0.25,0],[0,0.5,0],[0,0.75,0],[1,0.25,0],[1,0.5,0],[1,0.75,0]];outlineConnect=0;fontColor=#232F3E;fillColor=<COLOR>;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.<SERVICE>productIcon (70x100, taller with service header bar)
productIcon(70x100,更高,带服务标题栏)
| Service | prIcon |
|---|---|
| SQS | |
Style template:
sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;whiteSpace=wrap;fontSize=12;fontStyle=0;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.<SERVICE>| 服务 | prIcon |
|---|---|
| SQS | |
样式模板:
sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;whiteSpace=wrap;fontSize=12;fontStyle=0;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.<SERVICE>Standalone shapes (no resIcon needed)
独立形状(无需resIcon)
| Shape | shape value | fillColor |
|---|---|---|
| Client/Browser | | |
| Traditional Server | | |
| Firewall | | |
| ALB | | |
| NLB | | |
| VPC Endpoint | | |
| 形状 | shape值 | fillColor |
|---|---|---|
| 客户端/浏览器 | | |
| 传统服务器 | | |
| 防火墙 | | |
| ALB | | |
| NLB | | |
| VPC端点 | | |
Group boundaries
分组边界
| Group | grIcon | strokeColor |
|---|---|---|
| AWS Cloud | | |
| Account | | |
| On-premise | | |
| Corporate DC | | |
| VPC | | |
| Subnet (public) | | |
| Subnet (private) | | |
Container nesting (CRITICAL for grouping):
- ALL group/boundary shapes MUST include in their style
container=1;dropTarget=1; - Child cells inside a boundary MUST set instead of
parent="<boundary-cell-id>"parent="1" - This ensures moving a boundary moves all its children together
- Child geometry coordinates are relative to the parent container, not the canvas
- Cross-container edges: When source and target are in different containers, set the edge's
parent="1"
| 分组 | grIcon | strokeColor |
|---|---|---|
| AWS云 | | |
| 账户 | | |
| 本地环境 | | |
| 企业数据中心 | | |
| VPC | | |
| 子网(公有) | | |
| 子网(私有) | | |
容器嵌套(分组至关重要):
- 所有分组/边界形状必须在样式中包含
container=1;dropTarget=1; - 边界内的子单元格必须设置,而非
parent="<boundary-cell-id>"parent="1" - 此设置确保移动边界时会同时移动所有子元素
- 子元素的几何坐标相对于父容器,而非画布
- 跨容器边缘:当源和目标位于不同容器中时,将边缘的
parent="1"
BROKEN Icons — DO NOT USE
不可用图标——请勿使用
- — renders as empty colored square
resIcon=mxgraph.aws4.dynamodb_table - — renders as empty colored square
resIcon=mxgraph.aws4.dynamodb_stream - — renders as black square
resIcon=mxgraph.aws4.general_saml_token - — may not render
resIcon=mxgraph.aws4.endpoint - — unreliable
resIcon=mxgraph.aws4.kinesis_data_streams
Alternatives:
- DynamoDB tables/streams → use with descriptive labels
resIcon=mxgraph.aws4.dynamodb - External systems → use
shape=mxgraph.aws4.traditional_server - Browsers/clients → use
shape=mxgraph.aws4.client
- —— 渲染为空白彩色正方形
resIcon=mxgraph.aws4.dynamodb_table - —— 渲染为空白彩色正方形
resIcon=mxgraph.aws4.dynamodb_stream - —— 渲染为黑色正方形
resIcon=mxgraph.aws4.general_saml_token - —— 可能无法渲染
resIcon=mxgraph.aws4.endpoint - —— 不可靠
resIcon=mxgraph.aws4.kinesis_data_streams
替代方案:
- DynamoDB表/流 → 使用并添加描述性标签
resIcon=mxgraph.aws4.dynamodb - 外部系统 → 使用
shape=mxgraph.aws4.traditional_server - 浏览器/客户端 → 使用
shape=mxgraph.aws4.client
Audience Mode
受众模式
Before generating, assess the target audience:
- Technical: Use service names, protocol labels (HTTPS, gRPC), CIDR blocks, instance types
- Non-technical: Use action labels ("Store Data", "Send Notification"), hide implementation details, use numbered flow (① ② ③)
If unclear, ask: "Technical audience or executive/non-technical?"
生成前,评估目标受众:
- 技术受众:使用服务名称、协议标签(HTTPS、gRPC)、CIDR块、实例类型
- 非技术受众:使用动作标签(“存储数据”、“发送通知”),隐藏实现细节,使用编号流程(① ② ③)
若不确定,询问:“是面向技术受众还是高管/非技术受众?”
Numbered flow edges (for non-technical mode)
编号流程边缘(非技术模式)
Instead of technical labels, show flow order with circled numbers:
- Flow A: ① → ② → ③ → ④ (white circled numbers)
- Flow B: ❶ → ❷ → ❸ → ❹ (black circled numbers for second flow)
Use edge labels: with
value="①"fontSize=14;fontStyle=1;labelBackgroundColor=#ffffff;不使用技术标签,而是用带圈数字显示流程顺序:
- 流程A:① → ② → ③ → ④(白色带圈数字)
- 流程B:❶ → ❷ → ❸ → ❹(黑色带圈数字表示第二个流程)
使用边缘标签:并设置
value="①"fontSize=14;fontStyle=1;labelBackgroundColor=#ffffff;Companion Guide
配套指南
After generating the .drawio file, also generate a markdown guide:
- Same filename with extension
.md - Contents: diagram title, flow description (numbered steps), service list with purpose, key design decisions
生成.drawio文件后,还需生成markdown指南:
- 文件名与.drawio文件相同,扩展名为
.md - 内容:图表标题、流程描述(编号步骤)、服务列表及用途、关键设计决策
Two-Step Edit Approach
两步编辑法
After generating the initial .drawio file:
- Export to PNG using the draw.io CLI (see Export section)
- Review the PNG visually — check for empty/broken icons, overlapping edges, misaligned labels
- Fix issues in the .drawio XML and re-export
This catches rendering problems (wrong stencil names, broken styles) that are invisible in raw XML.
生成初始.drawio文件后:
- 导出为PNG:使用draw.io CLI(见导出章节)
- 视觉检查PNG:检查是否有空/损坏的图标、重叠的边缘、对齐错误的标签
- 修复问题:在.drawio XML中修复问题并重新导出
此步骤可捕获原始XML中不可见的渲染问题(错误的模板名称、损坏的样式)。
Icon Name Gotchas — CRITICAL
图标名称注意事项——至关重要
draw.io stencil names do NOT always match current AWS service names. Services that were renamed keep their legacy stencil names:
| AWS Service Name | draw.io resIcon name | Why |
|---|---|---|
| Amazon OpenSearch Service | | Renamed from Elasticsearch in 2021; |
| Amazon EventBridge | | Was CloudWatch Events |
| AWS Fargate | | Correct |
| VPC Peering | | Resource-level: |
| Amazon MSK | | NOT |
| IAM Identity Center | | NOT |
Rule: Always verify icon names from the reference files. If a service icon renders as an empty box, the stencil name is wrong. Check the draw.io source at for the canonical name.
src/main/webapp/js/diagramly/sidebar/Sidebar-AWS4.jsFallback for unmapped services: If a service is NOT found in any reference file, use this generic AWS cloud icon with the service name as label:
sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=#232F3E;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.general_AWScloudNever render an unknown service as a plain colored rectangle with no label.
draw.io模板名称并非始终与当前AWS服务名称匹配。已重命名的服务仍保留旧模板名称:
| AWS服务名称 | draw.io resIcon名称 | 原因 |
|---|---|---|
| Amazon OpenSearch Service | | 2021年从Elasticsearch重命名; |
| Amazon EventBridge | | 曾用名CloudWatch Events |
| AWS Fargate | | 名称正确 |
| VPC对等连接 | | 资源级: |
| Amazon MSK | | 请勿使用 |
| IAM身份中心 | | 请勿使用 |
规则: 始终从参考文件验证图标名称。如果服务图标渲染为空框,说明模板名称错误。查看draw.io源码获取标准名称。
src/main/webapp/js/diagramly/sidebar/Sidebar-AWS4.js未映射服务的 fallback 方案: 如果服务未在任何参考文件中找到,使用以下通用AWS云图标,并将服务名称作为标签:
sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=#232F3E;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.general_AWScloud绝不将未知服务渲染为无标签的普通彩色矩形。
Validation Step
验证步骤
After generating XML, verify:
- Every value exists in the reference files
resIcon= - Service-level icons have
strokeColor=#ffffff - Resource-level icons have
strokeColor=none - No XML comments present
- All cell IDs are unique
- Every edge has
<mxGeometry relative="1" as="geometry" /> - No icon uses a guessed stencil name — all verified against reference files
- Every edge has both and
sourceattributes referencing valid cell IDs (no floating edges)target - All group/boundary shapes include in their style
container=1;dropTarget=1; - Children inside boundaries use (not
parent="<boundary-id>")parent="1"
生成XML后,验证:
- 每个值均存在于参考文件中
resIcon= - 服务级图标设置
strokeColor=#ffffff - 资源级图标设置
strokeColor=none - 无XML注释
- 所有单元格ID唯一
- 每条边缘均包含
<mxGeometry relative="1" as="geometry" /> - 所有图标均使用已验证的模板名称,无猜测名称
- 每条边缘均包含和
source属性,引用有效的单元格ID(无浮动边缘)target - 所有分组/边界形状的样式中包含
container=1;dropTarget=1; - 边界内的子元素使用(而非
parent="<boundary-id>")parent="1"
Export
导出
For PNG/SVG/PDF export using draw.io Desktop CLI:
使用draw.io桌面CLI导出PNG/SVG/PDF:
Multi-page Diagrams
多页图表
For complex architectures, use multiple pages in one .drawio file:
xml
<mxfile>
<diagram id="overview" name="Overview">...</diagram>
<diagram id="networking" name="Networking Detail">...</diagram>
<diagram id="data-flow" name="Data Flow">...</diagram>
</mxfile>- Page 1: High-level overview (service-level icons only)
- Page 2+: Detail views (resource-level icons, subnet layouts, etc.)
对于复杂架构,在一个.drawio文件中使用多个页面:
xml
<mxfile>
<diagram id="overview" name="Overview">...</diagram>
<diagram id="networking" name="Networking Detail">...</diagram>
<diagram id="data-flow" name="Data Flow">...</diagram>
</mxfile>- 第1页:高层概述(仅服务级图标)
- 第2页及以后:详细视图(资源级图标、子网布局等)
Legend / Title Block
图例/标题块
Place in top-left corner, inside the background rectangle:
xml
<mxCell value="<b>Diagram Title</b><br>Author | Date | Version" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=14;spacing=8;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="300" height="50" as="geometry" />
</mxCell>放置在背景矩形内的左上角:
xml
<mxCell value="<b>Diagram Title</b><br>Author | Date | Version" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=14;spacing=8;" vertex="1" parent="1">
<mxGeometry x="40" y="40" width="300" height="50" as="geometry" />
</mxCell>PNG Export Background Fix
PNG导出背景修复
Place a rectangle covering the entire diagram as the bottom-most element to prevent black background on export.
#F5F5F5放置一个覆盖整个图表的矩形作为最底层元素,防止导出时出现黑色背景。
#F5F5F5Export CLI
导出CLI
| Platform | CLI Path |
|---|---|
| macOS | |
| Linux | |
| Windows | |
bash
<CLI> -x -f <format> -e -b 10 -o <output> <input>Flags: export, format (png/svg/pdf), embed diagram XML, border
-x-f-e-b 10Exported files use double extension: — signals embedded XML, re-editable in draw.io.
name.drawio.png| 平台 | CLI路径 |
|---|---|
| macOS | |
| Linux | |
| Windows | |
bash
<CLI> -x -f <format> -e -b 10 -o <output> <input>参数: 导出, 格式(png/svg/pdf), 嵌入图表XML, 边框
-x-f-e-b 10导出文件使用双重扩展名: —— 表示嵌入了XML,可在draw.io中重新编辑。
name.drawio.pngXML Well-formedness (CRITICAL)
XML格式正确性(至关重要)
- NEVER include XML comments () — they cause parse errors
<!-- --> - Escape special characters:
&<>" - Always use unique values for each mxCell
id - Every edge MUST have as child
<mxGeometry relative="1" as="geometry" /> - Root structure requires cells (root) and
id="0"(default layer, parent="0")id="1"
- 绝不包含XML注释() —— 会导致解析错误
<!-- --> - 转义特殊字符:
&<>" - 始终为每个mxCell使用唯一的值
id - 每条边缘必须包含作为子元素
<mxGeometry relative="1" as="geometry" /> - 根结构需要(根)和
id="0"(默认图层,parent="0")单元格id="1"