# 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

## Benefits

- 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.


## Installation

It requires ** python 3.6 ** version or heigher version python package

```
# using pip (pip3)
$ pip install diagrams

```


## Quick start

```
# SampleDiagram.py

from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network 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 SampleDiagram.py

```

output

![web_service.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660357226355/XxFsVCHok.png align="left")



## Example Clustered web service Infrastructure

```
#ClusterWebService.py

from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS, Lambda
from diagrams.aws.database import ElastiCache, RDS
from diagrams.aws.network import ELB, Route53
from diagrams.aws.integration import SQS
from diagrams.aws.storage 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"),
                     ECS("service2"),
                     ECS("service3")]

    #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 ClusterWebService.py

```

output

![clustered_web_services (1).png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660358835432/0FJdt2O-R.png align="left")


- Link to library [diagrams](https://diagrams.mingrammer.com/) 

- Github link : [Click here](https://github.com/mingrammer/diagrams)



**Keep Learning Keep Growing !!! **


## Community and Social Footprints :

- [Veerasolaiyappan](https://www.linkedin.com/in/veera26/) 
- [GitHub](https://github.com/cloudnloud)
- [Twitter](https://twitter.com/cloudnloud)
- [YouTube Cloud DevOps Free Trainings](https://www.youtube.com/c/CloudnLoud)
- [Linkedin Page](https://www.linkedin.com/company/cloudnloud/)
- [Linkedin Group](https://www.linkedin.com/groups/9124202/)
- [Discord Channel](https://discord.com/invite/vbjRQGVhuF)
- [Dev](https://dev.to/cloudnloud[Text](Link))










