Skip to content

Repository files navigation

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
Loading

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!

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages