Simples Diagrama as Code
Diagrama 01
1 #! /usr/bin/python3
2
3 from diagrams import Cluster, Diagram
4 from diagrams.aws.compute import EC2
5 from diagrams.aws.network import ELB
6 from diagrams.aws.security import WAF
7 from diagrams.aws.database import Aurora
8
9 with Diagram("Infra as <Code> - Sistemas em série", show=True):
10
11 with Cluster("Infra as <Code> - Sistemas em série"):
12 with Cluster("Front-end"):
13 front_end = [EC2("Front-end-01")]
14
15 with Cluster("Back-end"):
16 back_end = [EC2("Back-end-01")]
17
18
19 waf = WAF("WAF")
20 db = Aurora("DB")
21 fe_lb = ELB("Front-end-LB")
22 be_lb = ELB("Back-end-LB")
23
24
25 waf >> fe_lb >> front_end >> be_lb >> back_end >> db
Executando o código
./sistemas-em-serie.py
Diagrama 02
1#! /usr/bin/python3
2
3from diagrams import Cluster, Diagram
4from diagrams.aws.compute import EC2
5from diagrams.aws.network import ELB
6from diagrams.aws.database import Redshift
7from diagrams.aws.integration import SQS
8from diagrams.aws.storage import S3
9from diagrams.aws.security import WAF
10from diagrams.aws.database import Aurora
11
12with Diagram("Infra as <Code> - Sistemas em paralelo", show=True):
13
14 with Cluster("Infra as <Code> - Sistemas em paralelo"):
15 with Cluster("Front-end"):
16 front_end = [EC2("Front-end-01"),
17 EC2("Front-end-02"),
18 EC2("Front-end-03")]
19
20 with Cluster("Back-end"):
21 back_end = [EC2("Back-end-01"),
22 EC2("Back-end-02"),
23 EC2("Back-end-03")]
24
25
26
27 waf = WAF("WAF")
28 db = Aurora("DB")
29 fe_lb = ELB("Front-end-LB")
30 be_lb = ELB("Back-end-LB")
31
32
33 waf >> fe_lb >> front_end >> be_lb >> back_end >> db
Executando o código
./sistemas-em-paralelo.py
Abraços!
Vida longa e próspera a todos!!
Referências
- Diagrama 01 - https://github.com/leoml/blog-infraascode/blob/master/posts/availability-reliability/sistemas-em-serie.py
- Diagrama 02 - https://github.com/leoml/blog-infraascode/blob/master/posts/availability-reliability/sistemas-em-paralelo.py
MENTORIA
Curtiu o blog? Quer trocar uma ideia comigo sobre algum post?
Marca Aqui! É um papo gratuito
oferecido para quem é leitor do blog, podemos falar de temas como: DevOps, SRE e carreira em TI.
Te convido a ver os outros posts do blog Infra-as-Code garanto que tem coisas legais lá!!
|