DEV Community

Michael Wahl for AWS Community Builders

Posted on

Diagrams as Code DaC to go along with infrastructure as Code IaC

I have started using Diagrams which lets you easily draw/create cloud architecture using Python code!

This also allows you to visualize existing system architecture. The major providers are supported including AWS,Azure, and GCP. It also supports on-premise and SaaS applications.


The install is pretty straight forward, it does require python 3.6 or higher. Diagrams uses Graphviz to render the diagram, so you will need to install it first before you install and use Diagrams.

macOS users can download the Graphviz via brew install graphviz. Windows users fear not, you are not forgotten, and may use Chocolatey to run choco install graphviz.

# using pip (pip3)
$ pip install diagrams

# using pipenv
$ pipenv install diagrams

# using poetry
$ poetry add diagrams

Enter fullscreen mode Exit fullscreen mode

Demo or Quick Start

from diagrams import Diagram
from import EC2
from import RDS
from import ELB

with Diagram("Web Service", show=False):
    ELB("lb") >> EC2("web") >> EC2("web") >> EC2("web") >>  RDS("userdb")

Enter fullscreen mode Exit fullscreen mode

This generates the diagram below, saved as a png file within your working directory.

$ python3

Image description

More Info

Check out the Quick start guide

Check out the guides

Available nodes list

Top comments (0)