diagrams
diagrams copied to clipboard
make cluster ranks the same in for loop
given the code below i'm trying to get each vpc cluster to be on top of each other. typically i would do some penwidth=0 lines to keep everything ordered appropriately but i'm unclear on how to do that when the items were generated using a loop.
graph_attr = {
"arrowsize": "2",
"bgcolor": "white", # transparent
"overlap": "false",
"nodesep": "2.0",
"ranksep": "1.5",
"layout": "dot",
"compound": "false",
}
edge_attr = {
"penwidth": "2.0",
"pencolor": "gray",
}
subnet_attr = {"bgcolor": "lightgreen"}
environments = ["dev", "qa"]
azs = ["us-east-1b"]
online_vms = {}
with Diagram("Shared Services test", show=False, direction="TB", graph_attr={}, edge_attr={},filename="Shared/Diagrams/sharedsvcs") as diag1:
with Cluster("Example 1"):
tgw = TransitGateway("Shared Services TGW")
for env in environments:
with Cluster(f"{env} VPC"):
# Looping through Private first and then Public instead of doing it all in one for loop
# for rendering purposes (so it doesn't go private, public, private, public)
for az in azs:
with Cluster(f"{az}\nPrivate Subnet"):
instance = [
EC2Instance(f"Web Service"),
EC2Instance(f"inst2")
]
nic = VPCElasticNetworkInterface("TGW Connectivity")
# nic << Edge() >> tgw
for az in azs:
with Cluster(f"{az}\nPublic Subnet"):
alb = ALB(f"ALB")
# alb >> Edge() >> online_vms[env]
gw = NATGateway(f"NAT Gateway\nInternet Access")