Skip to content

Instantly share code, notes, and snippets.

@kevit
Created June 5, 2020 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevit/837e9f18cea7db00b8cd33bc418f9e05 to your computer and use it in GitHub Desktop.
Save kevit/837e9f18cea7db00b8cd33bc418f9e05 to your computer and use it in GitHub Desktop.
## group without clustering
with Diagram("AcctCreation", show=False):
begin = (
SQS("KickoffQueue")
>> Lambda("AcctCreate")
>> StepFunctions("StepFunctions")
)
with Cluster("StateMchne"):
with Cluster("Cncrrntx3.1"):
entry_lambda = Lambda("X")
out_lambda = Lambda("X")
entry_lambda >> out_lambda
inter_lambdas = out_lambda >> Lambda("X") >> Lambda("X")
with Cluster("Cncrrntx3"):
post_lambdas = inter_lambdas >> Lambda("X") >> Lambda("X")
store = S3("X")
store >> SNS("Notif")
post_lambdas >> [store, Lambda("MoveToOrg")]
begin >> entry_lambda
## Multilayer
from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.database import ElastiCache, RDS
from diagrams.aws.network import ELB
from diagrams.aws.network import Route53
class Layers(object):
def __init__(self, layer):
self.layer = layer
def get_diagram(self):
dns = Route53("dns")
lb = ELB("lb")
memcached = ElastiCache("memcached")
db_master = RDS("userdb")
svc_group = self.get_cluster()
dns >> lb >> svc_group
svc_group >> db_master
svc_group >> memcached
def get_cluster(self):
if self.layer == 1:
with Cluster("Services"):
return [ECS("web1"),
ECS("web2"),
ECS("web3")]
else:
return ECS("web")
with Diagram("Layer1", show=False):
cluster = Layers(1)
cluster.get_diagram()
with Diagram("Layer2", show=False):
cluster = Layers(2)
cluster.get_diagram()
## Color line
from diagrams import Diagram, Cluster, Edge
from diagrams.aws.compute import EC2
def colored_flow(*nodes):
for n1, n2 in zip(nodes, nodes[1:]):
n1 >> Edge(color="orange") >> n2
with Diagram("diag", show=False):
with Cluster("clst"):
colored_flow(
EC2("h1"),
EC2("h2"),
EC2("h3"),
EC2("h4"),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment