# diagram.py from diagrams import Diagram from diagrams.aws.network import CF from diagrams.aws.storage import S3 with Diagram("Static site", show=False): S3("Logging Bucket") << S3("Private Bucket") << CF("Public website")
users - dns >> web_servers web_servers >> Backbone Backbone >> app_servers app_servers >> db_master app_servers >> nfs with Diagram("AWS web application", show=True): users = Users('website/mobile users') with Cluster("Ingress"): dns = Route53("Route53") with Cluster("Cloudfront CDN"): s3_content = S3('Shared content') cf = CF('Cloudfront CDN') with Cluster('VPC'): with Cluster("WebProxy AutoScalingGroup (ASG)"): web_asg = AutoScaling('ASG') web_lb = ELB("NLB") with Cluster("Application servers AutoScalingGroup (ASG)"): app_asg = AutoScaling('ASG') app_lb = ELB("NLB") with Cluster("AWS Batch"): cwa = cw('CW Event') batch_s3 = S3('Batch data') batch = Batch('AWS Batch')
users = Users() with Cluster("AWS"): security = Cognito("Cognito") gateway = APIGateway("Gateway") route = Route53("Route53") db = DDB("DynamoDB") email_service = SES("SES") monitoring = Cloudwatch("AWS CloudWatch ") firewall = WAF("AWS WAF") identity = IAM("AWS IAM") with Cluster("CDN"): cdn = S3("S3") >> CF("CloudFront CDN") with Cluster("Functions") as xyz: func_send_mail = Lambda("Send Email") func_store_data = Lambda("Store Data") functions = [func_send_mail, func_store_data] gateway >> Edge() << functions functions >> Edge() << identity func_send_mail >> Edge() >> email_service >> users func_store_data - Edge() - db cdn >> Edge() << route # Monitoring log_connection = Edge(color="darkpink", style="dotted")
""" quick start from diagrams """ from diagrams import Diagram from diagrams.aws.compute import EC2 from diagrams.aws.database import RDS from diagrams.aws.network import ELB, CF from diagrams.aws.storage import S3, EFS with Diagram("Web Service", show=True): workers = [ EC2("1-web"), ] shared = EFS('wp-content') balancer = ELB('lb') cdn = CF('cdn') static = S3('wp-static') db = RDS('wp-tables') balancer >> workers >> db workers >> static workers >> shared cdn >> static
from diagrams import Diagram, Cluster, Edge from diagrams.aws.compute import EC2 from diagrams.aws.database import Aurora, DDB from diagrams.aws.network import VPC, CF, ELB, InternetGateway, NATGateway from diagrams.aws.storage import S3 with Diagram("AWS Simple Architecture", show=False, outformat="png"): cf = CF("CloudFront") with Cluster("VPC"): with Cluster("Private Subnet"): with Cluster("App"): servers_group = [EC2("app1"), EC2("app2"), EC2("app3")] with Cluster("Aurora Cluster"): aurora_writer = Aurora("Writer") aurora_writer - Aurora("Reader") with Cluster("Public Subnet"): elb = ELB("ALB") igw = InternetGateway("IGW") bastion = EC2("Bastion") >> Edge(label="login") >> servers_group[0] cf >> igw >> elb >> servers_group servers_group[0] >> aurora_writer
users >> s3 with Diagram("Terrascan Website", show=False, filename="02-s3-block-public-access"): users = Users("users") with Cluster("Private Only"): s3 = S3("static-assets") with Diagram("Terrascan Website", show=False, filename="03-s3-behind-cloudfront"): users = Users("users") with Cluster("Internet Exposed"): cf = CF("CDN") with Cluster("Private Only"): s3 = S3("static-assets") users >> cf >> s3 with Diagram("Terrascan Website", show=False, filename="04-public-elb-behind-cloudfront"): users = Users("users") with Cluster("Internet Exposed"): cf = CF("CDN") elb = ELB("Load Balancer") with Cluster("Private Only"): s3 = S3("static-assets") ec2 = EC2("app-server")
from diagrams import Cluster, Diagram from diagrams.aws.compute import ECS from diagrams.aws.network import Route53, CF from diagrams.aws.storage import S3 from diagrams.aws.management import Cloudformation from diagrams.onprem.vcs import Github from diagrams.onprem.network import Internet with Diagram("NateGramer.com - S3 Backed Public Website", show=False): with Cluster("Feature Branch Stack"): featureDns = Route53("<branch>.NateGramer.com") featureCloudfront = CF("CloudFront Distribution") featureBucket = S3("Site Storage") featureStack = [featureDns, featureCloudfront, featureBucket] featureDns >> featureCloudfront >> featureBucket Github("Pull in any feature branch") >> Cloudformation( "Branch Stack") >> featureStack Internet() >> featureDns with Cluster("Dev Branch Stack"): devDns = Route53("dev.NateGramer.com") devCloudfront = CF("CloudFront Distribution") devBucket = S3("Site Storage") devStack = [devDns, devCloudfront, devBucket] devDns >> devCloudfront >> devBucket Github("Push in Dev Branch") >> Cloudformation("Branch Stack") >> devStack Internet() >> devDns with Cluster("Master Branch Stack"):
#!/usr/bin/env python3 from diagrams import Diagram, Cluster from diagrams.aws.compute import ECS from diagrams.aws.database import Aurora from diagrams.aws.network import ELB, CF with Diagram("Example Architecture", show=False, direction="TB"): cf = CF('CloudFront') elb = ELB('ALB') admin_elb = ELB('Admin ELB') with Cluster('ECS Cluster'): ecs_cluster = [ECS('ECS1'), ECS('ECS2')] with Cluster('ECS Admin Cluster'): admin_cluster = [ECS('ECS1'), ECS('ECS2')] with Cluster('Aurora Cluster'): master = Aurora('master') slave = Aurora('slave') master - slave cf >> elb >> ecs_cluster >> master admin_elb >> admin_cluster >> master