https://github.com/awslabs/diagram-as-code

Diagram-as-code for AWS architecture.

https://github.com/awslabs/diagram-as-code

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.8%) to scientific vocabulary

Keywords

aws diagram-as-code
Last synced: 6 months ago · JSON representation

Repository

Diagram-as-code for AWS architecture.

Basic Info
  • Host: GitHub
  • Owner: awslabs
  • License: apache-2.0
  • Language: Go
  • Default Branch: main
  • Homepage:
  • Size: 5.66 MB
Statistics
  • Stars: 1,124
  • Watchers: 13
  • Forks: 73
  • Open Issues: 45
  • Releases: 19
Topics
aws diagram-as-code
Created about 2 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License Code of conduct Notice

README.md

Diagram-as-code

This command line interface (CLI) tool enables drawing infrastructure diagrams for Amazon Web Services through YAML code. It facilitates diagram-as-code without relying on image libraries.

The CLI tool promotes code reuse, testing, integration, and automating the diagramming process. It allows managing diagrams with Git by writing human-readable YAML.

Example templates are here. Check out the Introduction Guide as well for additional information.

CLI Usage animation

Getting started

for Gopher (go 1.21 or higher)

$ go install github.com/awslabs/diagram-as-code/cmd/awsdac@latest

for macOS user

$ brew install awsdac

Usage

``` Usage: awsdac [flags]

Flags: -c, --cfn-template [beta] Create diagram from CloudFormation template -d, --dac-file [beta] Generate YAML file in dac (diagram-as-code) format from CloudFormation template -h, --help help for awsdac -o, --output string Output file name (default "output.png") --override-def-file string For testing purpose, override DefinitionFiles to another url/local file -t, --template Processes the input file as a template according to text/template. -v, --verbose Enable verbose logging --version version for awsdac ```

Example

$ awsdac examples/alb-ec2.yaml

$ awsdac privatelink.yaml -o custom-output.png

[Beta] Create a diagram from CloudFormation template

--cfn-template option allows you to generate diagrams from CloudFormation templates, providing a visual representation of the resources. The tool can generate diagrams even if the CloudFormation template is not in a perfect format, enabling you to visualize the resources before actually creating the CloudFormation stack. This means you don't have to strictly adhere to the CloudFormation syntax constraints.

NOTE: The functionality of generating diagrams from CloudFormation templates is currently in beta. It sometimes works correctly, but we are aware of several known issues where the tool might not produce accurate results. We are actively working on improving the tool and fixing these issues.

$ awsdac examples/vpc-subnet-ec2-cfn.yaml --cfn-template (generated from the example of VPC,Subnet,EC2)

There are some patterns where the tool may not work as expected. You can find a list of known issues and their status on the issue tracker. Your feedback and issue reports are appreciated, as they will help enhance the tool's performance and accuracy.

Use "--dac-file" option

$ awsdac examples/vpc-subnet-ec2-cfn.yaml --cfn-template --dac-file CloudFormation templates have various dependencies, and there is no simple parent-child relationship between resources. As a result, generating the desired diagram directly from the existing CloudFormation template formats can be challenging at this stage. We considered utilizing Metadata or comments within the CloudFormation templates to include additional information. However, this approach would make the templates excessively long, and CloudFormation templates are primarily intended for resource creation and management rather than diagram generation. Additionally, combining different lifecycle components into a single CloudFormation template could make it difficult to manage and maintain.

Therefore, instead of directly generating diagrams from CloudFormation templates, you can create a separate YAML file from CloudFormation template and customize this YAML file. This customized YAML file can then be used as input for awsdac to generate the desired architecture diagrams. By decoupling the diagram generation process from the CloudFormation template structure, this approach offers greater flexibility and customization while leveraging the specialized strengths of awsdac. CloudFormation template --[awsdac]--> yaml file in awsdac format --[user custom]--> your desired diagram :)

Features

  • Compliant with AWS architecture guidelines
    Easily generate diagrams that follow AWS diagram guidelines.
  • Flexible
    Automatically adjust the position and size of groups.
  • Lightweight & CI/CD-friendly
    Start quickly on a container; no dependency on headless browser or GUI.
  • Integrate with your Infrastructure as Code
    Generate diagrams to align with your IaC code without managing diagrams manually.
  • As a drawing library
    Use as Golang Library and integrate with other IaC tools, AI, or drawing GUI tools.
  • Extensible
    Add definition files to create non-AWS diagrams as well.

MCP Server Integration

The awsdac MCP server enables AI assistants and development tools to generate AWS architecture diagrams programmatically through the Model Context Protocol (MCP). This integration allows seamless diagram creation within your development workflow.

Installation & MCP Client configuration

for macOS user

bash brew install awsdac

MCP Client configuration: json { "mcpServers": { "awsdac-mcp-server": { "command": "/opt/homebrew/bin/awsdac-mcp-server" } } }

MCP Client configuration with custom log: json { "mcpServers": { "awsdac-mcp-server": { "command": "/opt/homebrew/bin/awsdac-mcp-server", "args": ["--log-file", "/path/to/custom/awsdac-mcp.log"] } } }

for Gopher (go 1.21 or higher)

bash go install github.com/awslabs/diagram-as-code/cmd/awsdac-mcp-server@latest

json { "mcpServers": { "awsdac-mcp-server": { "command": "/Users/yourusername/go/bin/awsdac-mcp-server" } } }

Note: Replace /Users/yourusername with your actual home directory path.

Finding your binary location

If you installed via go install, you can find the binary location using:

```bash

Check if awsdac-mcp-server is in your PATH

which awsdac-mcp-server

Or check common Go install locations

ls ~/go/bin/awsdac-mcp-server ls $GOPATH/bin/awsdac-mcp-server # if GOPATH is set ```

Use the path returned by these commands in your MCP client configuration.

Custom Log File (Optional)

Available Tools

generateDiagram

Generates AWS architecture diagrams from YAML specifications and returns base64-encoded PNG images.

Parameters: - yamlContent (required): Complete YAML specification following the diagram-as-code format

generateDiagramToFile

Same as generateDiagram but saves the image directly to a specified file path.

Parameters: - yamlContent (required): Complete YAML specification - outputFilePath (required): Path where the PNG file should be saved

getDiagramAsCodeFormat

Returns comprehensive format specification, examples, and best practices for creating diagram-as-code YAML files.

Usage Examples

Generate an AWS architecture diagram showing a VPC with public and private subnets, an ALB, and EC2 instances.

However, if the MCP host cannot receive large-sized image data from the MCP server, please use generateDiagramToFile to save the image data directly to a file.

To save directly to a file: Generate an AWS architecture diagram showing a VPC with public and private subnets, an ALB, and EC2 instances, then save it to /tmp/test-diagram.png.

Troubleshooting

Connection Issues

  • Verify the MCP server binary path in your configuration
  • Check that the binary has execution permissions
  • Review log files for error messages

Log Files

By default, logs are written to /tmp/awsdac-mcp-server.log.

To use a custom log file location, add the --log-file argument to your MCP client configuration: json "args": ["--log-file", "/path/to/your/custom.log"]

Check the log file for detailed error messages and debugging information.

Resource types

See doc/resource-types.md.

Resource Link

See doc/links.md.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Owner

  • Name: Amazon Web Services - Labs
  • Login: awslabs
  • Kind: organization
  • Location: Seattle, WA

AWS Labs

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 72
  • Total pull requests: 199
  • Average time to close issues: 16 days
  • Average time to close pull requests: about 10 hours
  • Total issue authors: 15
  • Total pull request authors: 10
  • Average comments per issue: 0.32
  • Average comments per pull request: 0.1
  • Merged pull requests: 169
  • Bot issues: 0
  • Bot pull requests: 5
Past Year
  • Issues: 37
  • Pull requests: 64
  • Average time to close issues: 12 days
  • Average time to close pull requests: 1 day
  • Issue authors: 12
  • Pull request authors: 9
  • Average comments per issue: 0.24
  • Average comments per pull request: 0.19
  • Merged pull requests: 50
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • ugwis (40)
  • a2ush (17)
  • moltar (2)
  • pchaganti (2)
  • mikicz (1)
  • farzadmf (1)
  • bhatt-priyadutt (1)
  • PeskyPotato (1)
  • gruvy245 (1)
  • vazkarvishal (1)
  • gautaz (1)
  • phene (1)
  • dcaruso-pathpoint (1)
  • austinsonger (1)
  • GiamPy5 (1)
Pull Request Authors
  • ugwis (132)
  • a2ush (52)
  • dependabot[bot] (5)
  • naomori (3)
  • smalldave (2)
  • ryota-sakamoto (1)
  • judenfly (1)
  • 0b11stan (1)
  • PeskyPotato (1)
  • mattburgess (1)
Top Labels
Issue Labels
cfn-template feature (10) improvement (9) bug (7) enhancement (3) new feature (3) documentation (2)
Pull Request Labels
dependencies (5) go (1) bug (1) github_actions (1)

Packages

  • Total packages: 2
  • Total downloads:
    • homebrew 141 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 25
proxy.golang.org: github.com/awslabs/diagram-as-code
  • Versions: 13
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 8.6%
Average: 9.1%
Dependent repos count: 9.7%
Last synced: 6 months ago
formulae.brew.sh: awsdac

CLI tool for drawing AWS architecture

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 141 Last month
Rankings
Dependent packages count: 19.0%
Average: 43.9%
Dependent repos count: 55.0%
Downloads: 57.5%
Last synced: 6 months ago

Dependencies

.github/workflows/release.yml actions
  • actions/checkout v2 composite
  • actions/download-artifact v2 composite
  • actions/upload-artifact v2 composite
go.mod go
  • github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
  • github.com/sirupsen/logrus v1.9.3
  • golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
  • golang.org/x/image v0.15.0
  • golang.org/x/sys v0.17.0
  • gopkg.in/yaml.v3 v3.0.1
go.sum go
  • github.com/davecgh/go-spew v1.1.0
  • github.com/davecgh/go-spew v1.1.1
  • github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
  • github.com/pmezard/go-difflib v1.0.0
  • github.com/sirupsen/logrus v1.9.0
  • github.com/sirupsen/logrus v1.9.3
  • github.com/stretchr/objx v0.1.0
  • github.com/stretchr/testify v1.7.0
  • github.com/yuin/goldmark v1.4.13
  • golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
  • golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
  • golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
  • golang.org/x/image v0.7.0
  • golang.org/x/image v0.15.0
  • golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
  • golang.org/x/mod v0.8.0
  • golang.org/x/net v0.0.0-20190620200207-3b0461eec859
  • golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
  • golang.org/x/net v0.0.0-20220722155237-a158d28d115b
  • golang.org/x/net v0.6.0
  • golang.org/x/sync v0.0.0-20190423024810-112230192c58
  • golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
  • golang.org/x/sync v0.1.0
  • golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
  • golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
  • golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
  • golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
  • golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
  • golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
  • golang.org/x/sys v0.5.0
  • golang.org/x/sys v0.17.0
  • golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
  • golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
  • golang.org/x/term v0.5.0
  • golang.org/x/text v0.3.0
  • golang.org/x/text v0.3.3
  • golang.org/x/text v0.3.7
  • golang.org/x/text v0.7.0
  • golang.org/x/text v0.9.0
  • golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
  • golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e
  • golang.org/x/tools v0.1.12
  • golang.org/x/tools v0.6.0
  • golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
  • gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
  • gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
  • gopkg.in/yaml.v3 v3.0.1