Last active
July 19, 2024 12:05
-
-
Save rodmhgl/9ebd901b6583ab1df598dbf068b0987d to your computer and use it in GitHub Desktop.
Creates two simple diagrams using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from diagrams import Cluster, Diagram, Edge | |
from diagrams.azure.general import Usericon, Resourcegroups | |
from diagrams.azure.compute import ContainerInstances | |
from diagrams.azure.integration import APIManagement | |
from diagrams.azure.devops import Devops, Pipelines, Repos | |
graph_attrs = { | |
'bgcolor': 'snow2', | |
'fontsize': '48', | |
'labelloc': 'top', | |
'pad': '0.2', # Inches. | |
} | |
cluster_attrs = { | |
'fontsize': '14', | |
'labeljust': 'c', | |
'direction': 'LR' | |
} | |
node_attrs_no_lable = { | |
'width': '1.2', # Inches (1.4 is default). | |
'fontsize': '0', # Hide labels. | |
} | |
node_attrs = { | |
'width': '1.4', # Inches (1.4 is default). | |
'fontsize': '10', # Hide labels. | |
} | |
with Diagram(name="APIOps Azure Cloud Lab", filename='apiops', graph_attr=graph_attrs, show=False): | |
# Components (order matters!): | |
devuser = Usericon("enduser", **node_attrs_no_lable) | |
prduser = Usericon("enduser", **node_attrs_no_lable) | |
with Cluster("APIOPS-DEV-RG", graph_attr=cluster_attrs): | |
dev_web_ci = ContainerInstances("APIOPS-DEV-CG-WEB", **node_attrs) | |
dev_apim = APIManagement("APIOPSDEVAPIMLAB", **node_attrs) | |
dev_api_ci = ContainerInstances("APIOPS-DEV-CG-API", **node_attrs) | |
with Cluster("APIOPS-PRD-RG", graph_attr=cluster_attrs): | |
prd_web_ci = ContainerInstances("APIOPS-PRD-CG-WEB", **node_attrs) | |
prd_apim = APIManagement("APIOPSPRDAPIMLAB", **node_attrs) | |
prd_api_ci = ContainerInstances("APIOPS-PRD-CG-API", **node_attrs) | |
devuser >> dev_web_ci >> dev_apim >> dev_api_ci | |
devuser << dev_web_ci << dev_apim << dev_api_ci | |
prduser >> prd_web_ci >> prd_apim >> prd_api_ci | |
prduser << prd_web_ci << prd_apim << prd_api_ci | |
with Diagram(name="Azure DevOps Lab", filename='apiops_ado', graph_attr=graph_attrs, show=False): | |
with Cluster("Azure DevOps", graph_attr=graph_attrs): | |
Repos("APIOPSDEMO", **node_attrs) | |
extractor = Pipelines("Run-Extractor.yaml", **node_attrs) | |
publisher = Pipelines("Run-Publisher.yaml", **node_attrs) | |
publisherenv = Pipelines("Run-Publisher.yaml-with-env.yaml", **node_attrs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment