-
Notifications
You must be signed in to change notification settings - Fork 31
feat(deploy-on-aws): add architecture diagram generation skill #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| name: diagram | ||
| description: "Generate architecture diagrams as code using the Python diagrams DSL. Triggers on phrases like: architecture diagram, system design diagram, draw architecture, generate diagram, infrastructure diagram, AWS diagram, Kubernetes diagram, network diagram, visualize architecture." | ||
| --- | ||
|
|
||
| # Architecture Diagram Generation | ||
|
|
||
| Generate architecture diagrams using the Python [diagrams](https://diagrams.mingrammer.com/) package. Write a Python script, run it, and produce a PNG. | ||
|
|
||
| Supports AWS (29 service categories), Kubernetes, on-premises, GCP, SaaS, and custom icons via the `diagrams` DSL. | ||
|
|
||
| ## When to Load Reference Files | ||
|
|
||
| Load the appropriate reference file based on what the user is building: | ||
|
|
||
| - **Any diagram** -> ALWAYS load [references/dsl-syntax.md](references/dsl-syntax.md) first for DSL syntax, constructor options, connections, clusters, and edge styles | ||
| - **AWS architecture**, **cloud infrastructure**, or **AWS services** -> load [references/aws-services.md](references/aws-services.md) for AWS import paths, common icons, and 5 AWS examples | ||
| - **Kubernetes**, **on-premises**, **SaaS**, **flowcharts**, **sequence diagrams**, **custom icons**, or **non-AWS diagrams** -> load [references/non-aws-providers.md](references/non-aws-providers.md) for K8s, on-prem, flowchart, and custom icon examples | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Load [references/dsl-syntax.md](references/dsl-syntax.md) | ||
| 2. Load the relevant provider reference (AWS or non-AWS) | ||
| 3. Write a Python script using the `diagrams` DSL | ||
| 4. Run: `mkdir -p generated-diagrams && python diagram.py` | ||
| 5. Verify the PNG was created in `generated-diagrams/` | ||
|
Comment on lines
+24
to
+26
|
||
|
|
||
| ## Critical Rules | ||
|
|
||
| - ALWAYS set `show=False` in `Diagram()` constructor | ||
| - ALWAYS set `filename="generated-diagrams/<name>"` (no `.png` extension) | ||
| - ALWAYS use explicit imports: `from diagrams.aws.compute import EC2` | ||
| - ALWAYS run `mkdir -p generated-diagrams` before executing | ||
| - Use `Cluster()` to group related resources (VPCs, subnets, namespaces) | ||
| - Use `Edge(label=, color=, style=)` for labeled or styled connections | ||
|
|
||
| ## Defaults | ||
|
|
||
| Default output format: PNG | ||
| Default layout direction: TB (top-to-bottom) | ||
|
|
||
| Override syntax: | ||
|
|
||
| - "left to right" -> Use `direction="LR"` | ||
| - "SVG format" -> Use `outformat="svg"` | ||
|
|
||
| When not specified, ALWAYS use `direction="TB"` and `outformat="png"`. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Requires two dependencies installed locally: | ||
|
|
||
| 1. **GraphViz** (system package providing `dot`): | ||
| - macOS: `brew install graphviz` | ||
| - Ubuntu/Debian: `sudo apt-get install graphviz` | ||
| - Amazon Linux/RHEL: `sudo yum install graphviz` | ||
| 2. **Python diagrams package**: `pip install diagrams` | ||
|
|
||
| **Verify:** `dot -V && python3 -c "import diagrams; print('OK')"` | ||
|
|
||
| ### Missing Dependencies | ||
|
|
||
| If `dot` command not found: | ||
|
|
||
| - Inform user: "GraphViz is not installed. Required for diagram rendering." | ||
| - Show install command for detected OS | ||
| - DO NOT attempt to generate diagrams without GraphViz | ||
|
|
||
| If `import diagrams` fails: | ||
|
|
||
| - Inform user: "Python diagrams package not installed." | ||
| - Show: `pip install diagrams` | ||
| - DO NOT proceed without the package | ||
|
|
||
| ## References | ||
|
|
||
| - [DSL syntax and patterns](references/dsl-syntax.md) | ||
| - [AWS services and examples](references/aws-services.md) | ||
| - [Non-AWS providers and examples](references/non-aws-providers.md) | ||
| - [diagrams documentation](https://diagrams.mingrammer.com/) | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||||
| # AWS Services and Examples | ||||||||
|
|
||||||||
| ## AWS Service Categories | ||||||||
|
|
||||||||
| | Category | Import Path | Common Icons | | ||||||||
| |----------|------------|--------------| | ||||||||
| | `analytics` | `diagrams.aws.analytics` | Athena, EMR, Glue, Kinesis, Redshift, Quicksight | | ||||||||
| | `compute` | `diagrams.aws.compute` | EC2, Lambda, ECS, EKS, Fargate, Batch | | ||||||||
| | `database` | `diagrams.aws.database` | RDS, Aurora, DynamoDB, ElastiCache, Redshift, Neptune | | ||||||||
| | `integration` | `diagrams.aws.integration` | SQS, SNS, StepFunctions, EventBridge, MQ | | ||||||||
| | `management` | `diagrams.aws.management` | CloudWatch, CloudFormation, SystemsManager | | ||||||||
| | `ml` | `diagrams.aws.ml` | Sagemaker, Rekognition, Comprehend, Bedrock | | ||||||||
| | `network` | `diagrams.aws.network` | VPC, ELB, ALB, NLB, CloudFront, Route53, APIGateway | | ||||||||
| | `security` | `diagrams.aws.security` | IAM, Cognito, WAF, KMS, Shield, SecretsManager | | ||||||||
| | `storage` | `diagrams.aws.storage` | S3, EBS, EFS, FSx, Backup | | ||||||||
| | `general` | `diagrams.aws.general` | User, Users, Client, InternetGateway | | ||||||||
|
|
||||||||
| Other categories: `ar`, `blockchain`, `business`, `cost`, `devtools`, `enablement`, `enduser`, `engagement`, `game`, `iot`, `media`, `migration`, `mobile`, `quantum`, `robotics`, `satellite`. | ||||||||
|
|
||||||||
| ## Example: Basic Web Service | ||||||||
|
|
||||||||
| ```python | ||||||||
| from diagrams import Diagram | ||||||||
| from diagrams.aws.compute import EC2 | ||||||||
| from diagrams.aws.database import RDS | ||||||||
| from diagrams.aws.network import ELB | ||||||||
|
|
||||||||
| with Diagram("Web Service", show=False, filename="generated-diagrams/aws-basic"): | ||||||||
| ELB("lb") >> EC2("web") >> RDS("userdb") | ||||||||
| ``` | ||||||||
|
|
||||||||
| ## Example: Grouped Workers | ||||||||
|
|
||||||||
| ```python | ||||||||
| from diagrams import Diagram | ||||||||
| from diagrams.aws.compute import EC2 | ||||||||
| from diagrams.aws.database import RDS | ||||||||
| from diagrams.aws.network import ELB | ||||||||
|
|
||||||||
| with Diagram("Grouped Workers", show=False, direction="TB", filename="generated-diagrams/aws-workers"): | ||||||||
| ELB("lb") >> [EC2("w1"), EC2("w2"), EC2("w3"), EC2("w4"), EC2("w5")] >> RDS("events") | ||||||||
| ``` | ||||||||
|
|
||||||||
| ## Example: Clustered Web Services | ||||||||
|
|
||||||||
| ```python | ||||||||
| from diagrams import Diagram, Cluster | ||||||||
| from diagrams.aws.compute import ECS | ||||||||
| from diagrams.aws.database import RDS, ElastiCache | ||||||||
| from diagrams.aws.network import ELB, Route53 | ||||||||
|
|
||||||||
| with Diagram("Clustered Web Services", show=False, filename="generated-diagrams/aws-clustered"): | ||||||||
| dns = Route53("dns") | ||||||||
| lb = ELB("lb") | ||||||||
| with Cluster("Services"): | ||||||||
| svc_group = [ECS("web1"), ECS("web2"), ECS("web3")] | ||||||||
| with Cluster("DB Cluster"): | ||||||||
| db_primary = RDS("userdb") | ||||||||
| db_primary - [RDS("userdb ro")] | ||||||||
|
||||||||
| db_primary - [RDS("userdb ro")] | |
| db_replica = RDS("userdb ro") | |
| db_primary - db_replica |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,110 @@ | ||||||||||||||||||||||
| # Diagrams DSL Syntax Reference | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Basic Structure | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```python | ||||||||||||||||||||||
| from diagrams import Diagram, Cluster, Edge | ||||||||||||||||||||||
| from diagrams.aws.compute import EC2, Lambda | ||||||||||||||||||||||
| from diagrams.aws.database import RDS | ||||||||||||||||||||||
| from diagrams.aws.network import ELB | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| with Diagram("Title", show=False, filename="generated-diagrams/name"): | ||||||||||||||||||||||
| with Cluster("VPC"): | ||||||||||||||||||||||
| lb = ELB("ALB") | ||||||||||||||||||||||
|
Comment on lines
+9
to
+13
|
||||||||||||||||||||||
| from diagrams.aws.network import ELB | |
| with Diagram("Title", show=False, filename="generated-diagrams/name"): | |
| with Cluster("VPC"): | |
| lb = ELB("ALB") | |
| from diagrams.aws.network import ALB | |
| with Diagram("Title", show=False, filename="generated-diagrams/name"): | |
| with Cluster("VPC"): | |
| lb = ALB("ALB") |
Copilot
AI
Mar 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom node example downloads an icon at runtime via urlretrieve, which adds an external network dependency and can pull untrusted content. Prefer referencing a local icon file path (or document a separate, manual download step with integrity verification) so diagram generation is deterministic and safer.
| from urllib.request import urlretrieve | |
| icon_path, _ = urlretrieve("https://example.com/icon.png", "icon.png") | |
| # Use a local icon file. Download or place the icon in your project beforehand. | |
| icon_path = "icons/my-service.png" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The skill claims support for "sequence diagrams", but the Python
diagramsDSL (GraphViz-based) doesn't produce UML sequence diagrams. Please remove this trigger/category or clarify what diagram types are actually supported.