Skip to main content

A simple CLI script to generate AWS infrastructure diagrams from AWS CloudFormation templates

Project description

AWS CloudFormation Diagrams

license python version pypi version PyPI Downloadscontributors

An open source tool to generate AWS infrastructure diagrams from AWS CloudFormation templates.

Features

Have ideas? Open an issue or start a discussion.

Prerequisites

Following software must be installed:

Installation

Following command installs required Python dependencies, i.e., PyYAML, Diagrams, and graphviz2drawio.

# using pip (pip3)
pip install AWS-CloudFormation-Diagrams

Usage

usage: aws-cfn-diagrams [-h] [-o OUTPUT] [-f FORMAT] [--embed-all-icons] filename

Generate AWS infrastructure diagrams from AWS CloudFormation templates

positional arguments:
  filename             the AWS CloudFormation template to process

options:
  -h, --help           show this help message and exit
  -o, --output OUTPUT  output diagram filename
  -f, --format FORMAT  output format, allowed formats are d2, dot, dot_json, drawio, gif, jp2, jpe, jpeg, jpg, mermaid, pdf, png, svg, tif, tiff, set to png by default
  --embed-all-icons    embed all icons into svg or dot_json output diagrams

D2 Diagram Generation

AWS CloudFormation Diagrams could output diagrams in the D2 format. For instance, type:

aws-cfn-diagrams examples/wordpress/WordPress-RDS.yaml -f d2

After compiling with D2 CLI, the generated diagram is rendered as follows:

WordPress RDS Diagram

Mermaid Diagram Generation

AWS CloudFormation Diagrams could output diagrams in the Mermaid format. For instance, type:

aws-cfn-diagrams examples/wordpress/WordPress-RDS.yaml -f mermaid

The generated diagram is rendered as follows:

flowchart TB
  subgraph cluster_VpcId [VpcId]
    direction TB
    style cluster_VpcId fill:#f2e6ff,color:#2D3436,font:sans-serif,font-size:12pt,stroke:box
    subgraph cluster_WebSecurityGroup [WebSecurityGroup]
      direction TB
      style cluster_WebSecurityGroup fill:#fff5e6,color:#2D3436,font:sans-serif,font-size:12pt,stroke:box
      resource_WebSecurityGroup@{ img: "https://raw.githubusercontent.com/mingrammer/diagrams/refs/heads/master/resources/aws/compute/ec2.png", label: "WebSecurityGroup", h: 120, constraint: "on" }
      style resource_WebSecurityGroup fill:none,stroke:none
      resource_WordPressInstance@{ img: "https://raw.githubusercontent.com/mingrammer/diagrams/refs/heads/master/resources/aws/compute/ec2-instance.png", label: "WordPressInstance", h: 120, constraint: "on" }
      style resource_WordPressInstance fill:none,stroke:none
    end
    subgraph cluster_DBSecurityGroup [DBSecurityGroup]
      direction TB
      style cluster_DBSecurityGroup fill:#fff5e6,color:#2D3436,font:sans-serif,font-size:12pt,stroke:box
      resource_DBSecurityGroup@{ img: "https://raw.githubusercontent.com/mingrammer/diagrams/refs/heads/master/resources/aws/compute/ec2.png", label: "DBSecurityGroup", h: 120, constraint: "on" }
      style resource_DBSecurityGroup fill:none,stroke:none
      resource_WordPressDB@{ img: "https://raw.githubusercontent.com/mingrammer/diagrams/refs/heads/master/resources/aws/database/rds-mysql-instance.png", label: "WordPressDB", h: 120, constraint: "on" }
      style resource_WordPressDB fill:none,stroke:none
    end
    resource_VpcId@{ img: "https://raw.githubusercontent.com/mingrammer/diagrams/refs/heads/master/resources/aws/network/vpc.png", label: "VpcId", h: 120, constraint: "on" }
    style resource_VpcId fill:none,stroke:none
  end
  resource_WebSecurityGroup --> resource_VpcId
  linkStyle 0 stroke:black,color:#2D3436,font:sans-serif,font-size:13pt
  resource_WordPressInstance --> resource_WebSecurityGroup
  linkStyle 1 stroke:black,color:#2D3436,font:sans-serif,font-size:13pt
  resource_WordPressInstance --> resource_WordPressDB
  linkStyle 2 stroke:black,color:#2D3436,font:sans-serif,font-size:13pt
  resource_DBSecurityGroup --> resource_WebSecurityGroup
  linkStyle 3 stroke:black,color:#2D3436,font:sans-serif,font-size:13pt
  resource_DBSecurityGroup --> resource_VpcId
  linkStyle 4 stroke:black,color:#2D3436,font:sans-serif,font-size:13pt
  resource_WordPressDB --> resource_DBSecurityGroup
  linkStyle 5 stroke:black,color:#2D3436,font:sans-serif,font-size:13pt

Interactive Viewer

AWS CloudFormation Diagrams could output diagrams in the dot_json format. For instance, type:

aws-cfn-diagrams examples/wordpress/WordPress-RDS.yaml -f dot_json

Diagrams in the dot_json format can be viewed and manipulated interactively thanks to AWS CloudFormation Diagrams Interactive Viewer. Just type:

open interactive_viewer/index.html

Then open examples/wordpress/WordPress-RDS.dot_json in AWS CloudFormation Diagrams Interactive Viewer.

AWS CloudFormation Diagrams Interactive Viewer

AWS CloudFormation Diagrams Interactive Viewer allows users to zoom in/out diagrams, to see cluster/node/edge tooltips, open/close clusters, move clusters/nodes interactively, and save as PNG/JPG images.

Editable draw.io Export

AWS CloudFormation Diagrams could output diagrams in the drawio format. For instance, type:

aws-cfn-diagrams examples/wordpress/WordPress-RDS.yaml -f drawio

✨ Generated drawio files can be opened with draw.io or your favorite diagram editor.

AWS CloudFormation Diagrams in draw.io

Examples

The folder diagrams contains generated diagrams for most of AWS CloudFormation templates.

Following diagram is about WebApp:

WebApp

Following diagram is about Gitea with Rain::Module:

Gitea

Following diagram is about Gitea without Rain::Module:

Gitea

Following diagram is about AutoScaling:

AutoScaling

Following diagram is about EKS:

EKS

Following diagram is about VPC:

VPC

License

This project is licensed under the Apache 2.0 License.

Contributing

PRs and ideas are welcome!

Star History

Star History Chart

Star this project if you find it useful!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_cloudformation_diagrams-0.3.0.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_cloudformation_diagrams-0.3.0-py3-none-any.whl (44.5 kB view details)

Uploaded Python 3

File details

Details for the file aws_cloudformation_diagrams-0.3.0.tar.gz.

File metadata

File hashes

Hashes for aws_cloudformation_diagrams-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2ffb6aa81698246f525e903b21ad9f0a1133ddd7aa3969e15d3793c627b6a172
MD5 26a5ce76809b8afeb74847401a229aa7
BLAKE2b-256 6c146c71dcc08abe7efd9e42db130c37061a83ccc9b76ac7a567ad5091e20b26

See more details on using hashes here.

File details

Details for the file aws_cloudformation_diagrams-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_cloudformation_diagrams-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ea2d7ec2bea20946cd078edef1fb2bedc7fc3cc569602620ba89d093eb6d12d
MD5 78d7789f9bdbda41124fb6d8aae1a26f
BLAKE2b-256 6cf9cc2c2df60ba47a8511b65ca462fb73b2bb8dfebf0b961ac379bc178575db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page