Infrastructure Digrams as Code

Infrastructure Digrams as Code

Diagrams are playing one of the major role in software development, Architecture development and Cloud infrastructure building.

This python package diagrams is really helpful to Software architect, Solutions architect, Cloud engineers and Enterprise architect to keep our infrastructure diagram as code


  • Easy to understand
  • Help to simplify the process
  • Proper documentation
  • Versioning our infrastructure diagrams changes as code
  • Easy to customise
  • Open source

It's currently supports main major providers including: AWS, Azure, GCP, Kubernetes, Alibaba Cloud, Oracle Cloud etc... It also supports On-Premise nodes, SaaS and major Programming frameworks and languages.


It requires python 3.6 version or heigher version python package

# using pip (pip3)
$ pip install diagrams

Quick start


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

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

to run the above code in your terminal

$ python



Example Clustered web service Infrastructure

from diagrams import Cluster, Diagram
from import ECS, Lambda
from import ElastiCache, RDS
from import ELB, Route53
from import SQS
from import S3

#create diagram
with Diagram("Clustered Web Services", show=False):
    # route53  
    dns = Route53("dns")

    #Elastic load balancer
    lb = ELB("App load balancer")

    #Elastic containe service cluster
    with Cluster("Services"):
        svc_group = [ECS("service1"),

    #Simple queue service
    queue = SQS("SQS service")

    #Relational Database service db cluster
    with Cluster("RDS DB Cluster"):
        db_primary = RDS("userdb")
        db_primary - [RDS("backup")]

    #lambda functions cluster
    with Cluster("Lambdas"):
      handlers = [
          Lambda('Lambda 1'),
          Lambda('Lambda 2'),
          Lambda('Lambda 3'),

    #Elasticcache service
    memcached = ElastiCache("memcached")

    # S3 serive
    store = S3("File storage")

    #architecture work flow
    dns >> lb >> svc_group >> queue >> handlers
    handlers[0] >> memcached
    handlers[1] >> store
    handlers[2] >> db_primary

to run the code

$ python


clustered_web_services (1).png

Keep Learning Keep Growing !!!

Community and Social Footprints :

Did you find this article valuable?

Support Cloudnloud Tech Community by becoming a sponsor. Any amount is appreciated!