def generate_architecture_diagram(): # Use a much higher resolution than default graph_attr = {'dpi': '240'} with Diagram("", show=False, direction="TB", graph_attr=graph_attr, filename="simulation_server"): with Cluster(""): with Cluster(""): www = APIGateway("WWW") ws = DirectConnect("WebSocket") udp = AppMesh("UDP") server = EC2("Server") server - [udp, www, ws] browser = Client("Browser") www >> browser ws >> browser ws << browser device = AppServiceMobile("Device") udp >> device udp << device
def apigw_lambda(): stack_objective = "apigw-lambda" with Diagram(stack_objective, outformat="png", filename=f"{stack_objective}/pics/arch", show=False): APIGateway("APIGateway") >> Edge(label="integration") >> Lambda("task")
def backend( graph_attr: dict = GRAPH_ATTR, output_format: str = OUTPUT_FORMAT, output_path: str = OUTPUT_PATH, ) -> str: """ Generates backend diagrams """ output = f"{output_path}/backend" with Diagram( "Backend", show=False, outformat=output_format, # graph_attr=graph_attr, filename=output, ): with Cluster("Serverless"): apigw = APIGateway("API Gateway") with Cluster("Concurrent Processing"): handlers = [ Lambda("API (FastAPI)"), Lambda("API (FastAPI)"), Lambda("API (FastAPI)"), ] db = Dynamodb("data store") apigw >> handlers >> db >> handlers >> apigw return f"{output}.{output_format}"
def apigw_dynamodb_lambda(): stack_objective = "apigw-dynamodb-lambda" with Diagram(stack_objective, outformat="png", filename=f"{stack_objective}/pics/arch", show=False): apigw = APIGateway("/task") dynamodb = Dynamodb("DynamoDB") apigw >> Edge( label="POST /example/update") >> Lambda("update status") >> Edge( label="update item") >> dynamodb apigw >> Edge(label="POST /example") >> Lambda("producer") >> Edge( label="put item") >> dynamodb apigw >> Edge(label="GET /example") >> Lambda("consumer") >> Edge( label="read all item") >> dynamodb
def frontend( graph_attr: dict = GRAPH_ATTR, output_format: str = OUTPUT_FORMAT, output_path: str = OUTPUT_PATH, ) -> str: """ Generates frontend diagrams """ output = f"{output_path}/frontend" with Diagram( "Frontend", show=False, outformat=output_format, # graph_attr=graph_attr, filename=output, ): client = Client("client") with Cluster("Serverless"): with Cluster("UI"): with Cluster("cache"): web_cdn = CloudFront("CDN\nUI") with Cluster("static"): web_host = S3("web") react = React("app") with Cluster("Static Assets"): with Cluster("cache"): assets_cdn = CloudFront("CDN\nassets") assets_apigw = APIGateway("API Gateway") assets = S3("assets\nimages") with Cluster("media processing"): assets_gen = Lambda("generate image") layers = Layer("layer\nImageMagick") web_cdn << react << web_host assets_cdn << assets_apigw << assets_gen << layers << assets client - Edge(color="orange") << assets_cdn client - Edge(color="orange") << web_cdn assets_apigw >> assets_gen assets_cdn >> assets_apigw return f"{output}.{output_format}"
def apigw_dynamodb_sfn_with_heavytask(): stack_objective = "apigw-dynamodb-sfn-with-heavytask" with Diagram(stack_objective, outformat="png", filename=f"{stack_objective}/pics/arch", show=False): sqs = SQS("SQS") apigw = APIGateway("/task") >> Lambda("integration") >> [ sqs, Dynamodb("DynamoDB") ] timer_lambda = Lambda("timer lambda") sqs << Edge(label="dequeue") << timer_lambda << Cloudwatch("cron") with Cluster(label="StepFunctions", direction="TB"): sfn_start = SFn_TASK("update DynamoDB\nset `running`") sfn_start \ >> Lambda("Some Task") \ >> [SFn_TASK("update DynamoDB\nset `success`"), SFn_TASK("update DynamoDB\nset `failure`")] # invoke sfn from Lambda timer_lambda >> sfn_start
with Diagram( "CC3 AWS Connect High Level Architecture", filename="architecture", outformat="png", show=False, direction="BT", ): connect = Connect("Connect") connectLambda = Lambda("awsConnect") web = Vue("CCU3 Web") api = Django("CCU3 Api") users = [Users("Users"), Users("Agents")] with Cluster("CCU3 awsconnect"): gateway = APIGateway("Websocket Gateway") database = Dynamodb("ConnectClientsDB") with Cluster("Websocket Handler"): with Cluster("Connection"): connectionHandlers = [Lambda("$connect" + str(i)) for i in range(3)] gateway - connectionHandlers connectionHandlers >> database with Cluster("Messaging"): wsHandlers = [Lambda("$default" + str(i)) for i in range(3)] gateway - wsHandlers wsHandlers - api wsHandlers >> database
from diagrams.aws.database import DDB from diagrams.aws.management import Cloudwatch graph_attr = {"fontsize": "40"} with Diagram("Static Website on Amazon S3 ", filename="diagram", show=False, graph_attr=graph_attr): 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
from diagrams import Diagram from diagrams.aws.compute import Lambda from diagrams.aws.database import DynamodbTable from diagrams.aws.integration import SNS from diagrams.aws.network import APIGateway with Diagram("Calendar Events", show=False, direction="TB"): events = Lambda("calendar events") topic = SNS("calendar topic") APIGateway("calendar events api") >> events >> DynamodbTable( "calendar events") >> events events >> topic
from diagrams import Cluster, Diagram, Edge from diagrams.aws.compute import Lambda from diagrams.aws.network import APIGateway from diagrams.onprem.compute import Server with Diagram("Dynamic Rendering API", show=False): server = Server("web page") with Cluster("Dynamic Rendering"): api = APIGateway("api") fn = Lambda("puppeteer") api >> fn >> server
from diagrams import Diagram from diagrams.aws.compute import Lambda from diagrams.aws.integration import SNS from diagrams.aws.network import APIGateway with Diagram("Calendar User Agent", show=False, direction="TB"): cua = Lambda("calendar user agent") # APIGateway("calendar user agent api") >> cua topic = SNS("calendar topic") events = APIGateway("calendar events") tasks = APIGateway("calendar tasks") journal = APIGateway("calendar journal") availability = APIGateway("calendar availability") topic >> cua >> topic events >> cua >> events tasks >> cua >> tasks journal >> cua >> journal availability >> cua >> availability
from diagrams import Diagram from diagrams.aws.compute import Lambda from diagrams.aws.database import DynamodbTable from diagrams.aws.integration import SNS from diagrams.aws.network import APIGateway with Diagram("User Profile", show=False, direction="TB"): userprofile = Lambda("user profile") # topic = SNS("user profile") APIGateway("user profile api") >> userprofile >> DynamodbTable("user profiles") >> userprofile # userprofile >> topic
# diagram.py from diagrams import Diagram, Edge from diagrams.aws.compute import Lambda from diagrams.aws.storage import S3 from diagrams.aws.network import APIGateway from diagrams.aws.integration import SQS from diagrams.onprem.network import Internet from diagrams.elastic.elasticsearch import Beats, Elasticsearch, Kibana, Logstash with Diagram("node-sass mirror", show=False, outformat="png", filename="overview"): inet = Internet("Internet") s3_bucket = S3(label="S3 Bucket") gw = APIGateway(label="API Gateway") lambda_function = Lambda("Lambda function") message_queue = SQS(label="Processing Queue") dl_queue = SQS(label="Dead Letter Queue") inet >> gw >> message_queue message_queue >> dl_queue message_queue >> Edge(label="triggers") >> lambda_function lambda_function >> Edge(label="uploads asset to ") >> s3_bucket s3_bucket >> Edge(label="download for whitelisted addresses") >> inet
from diagrams import Diagram from diagrams.aws.network import APIGateway from diagrams.aws.compute import Lambda from diagrams.aws.database import RDS with Diagram("fiber-aws-serverless", filename="./docs/aws_diagram", show=False): APIGateway("http-gateway") >> Lambda("fiber-app") >> RDS("aws RDS")
# https://diagrams.mingrammer.com/docs/nodes/aws from diagrams import Cluster, Diagram from diagrams.aws.compute import Lambda from diagrams.aws.general import User from diagrams.aws.network import APIGateway from diagrams.aws.database import DynamodbTable from diagrams.onprem.client import Client from diagrams.aws.devtools import CommandLineInterface with Diagram("Serverless Web App Workflow", show=False, direction="LR"): user = User("User") console = Client("Browser") api = APIGateway("API Gateway") mylambda = Lambda("Lambda") ddb = DynamodbTable("DynamodbTable") user >> console >> api >> mylambda >> ddb
broker = Eventbridge() with Cluster("Lot Selection"): inbox = S3("Listings") listing_queue = SQS() textract = Lambda("Extract lots") listings_db = Dynamodb("Listings db") selector = Lambda("Select lots") inbox >> listing_queue >> textract >> listings_db >> selector with Cluster("Buying app"): pricer = Lambda("Bid calculator") purchases = Dynamodb("Buying db") apig = APIGateway("Manager app") ls = Lambda("View proposals") put = Lambda("Set price") invoices = S3("Invoice bucket") invoice_listener = Lambda("Invoice listener") listener = Lambda("Lot listener") listener >> pricer >> purchases apig >> ls >> purchases apig >> put >> purchases invoices >> invoice_listener >> purchases selector >> broker broker >> listener
from diagrams.aws.network import APIGateway from diagrams.aws.storage import S3 from diagrams.onprem.client import User from diagrams.onprem.ci import TravisCI from diagrams.onprem.vcs import Git from diagrams.onprem.compute import Server from diagrams.programming.language import Rust with Diagram("Lambda Rust Test", show=False): developer = User("Developer") travis = TravisCI("TravisCI") codecov = Server("Codecov") rust = Rust("Rust") with Cluster("Serverless Offline (Local)"): local_api_gateway = APIGateway("API Gateway (Virtual)") local_lambda = Lambda("Lambda (Virtual)") local_s3 = S3("S3 (Virtual)") local_api_gateway >> local_lambda >> local_s3 with Cluster("Github"): master_branch = Git("branch (master)") release_branch = Git("branch (release)") with Cluster("AWS (release)"): release_lambda = Lambda("Lambda") release_api_gateway = APIGateway("API Gateway") release_s3 = S3("S3") release_api_gateway >> release_lambda >> release_s3 with Cluster("AWS (dev)"):
from diagrams import Cluster, Diagram, Edge from diagrams.aws.network import Cloudfront from diagrams.aws.storage import S3 from diagrams.onprem.client import Users, User from diagrams.aws.compute import Lambda from diagrams.aws.network import APIGateway from diagrams.onprem.compute import Server with Diagram("Dynamic Rendering Lambda Edge", show=False): with Cluster("SPA Site"): cf = Cloudfront("Cloudfront") s3 = S3("static\nhosting") vreq = Lambda("Viewer\nRequest") oreq = Lambda("Origin\nRequest") api = APIGateway("Dynamic\nRendering\nAPI") users = Users("User") crawler = User("Crawler") users >> cf crawler >> cf cf >> vreq >> Edge(label="add header") >> oreq oreq >> Edge(label="if user") >> s3 oreq >> Edge(label="if crawler") >> api >> Edge(label="as user") >> cf
from diagrams import Cluster, Diagram from diagrams.aws.compute import Lambda, Fargate from diagrams.aws.database import Dynamodb from diagrams.aws.integration import SQS, SNS, SF from diagrams.aws.network import APIGateway from diagrams.aws.storage import S3 from diagrams.aws.analytics import Kinesis, KinesisDataFirehose with Diagram("Lambda Pinball", show=False): bucket = S3("bucket") ddb = Dynamodb("database") apig = APIGateway("HTTP") tsp = Lambda("Transpangler") steps = [SF("Step 1"), SF("Step 2"), SF("Step 3")] apig >> Lambda("POST handler") >> ddb >> Lambda( "Stream Listener") >> Kinesis("Event stream") >> KinesisDataFirehose( "Firehose") >> bucket >> SNS("Notifier") >> SQS( "Job queue") >> tsp >> steps >> bucket >> SNS( "Finished") >> Lambda("on finished") >> ddb tsp >> ddb tsp >> bucket steps >> ddb apig >> Lambda("GET handler") >> ddb
from diagrams.aws.compute import Lambda from diagrams.aws.storage import S3 from diagrams.aws.network import APIGateway from diagrams.aws.database import DynamodbTable from diagrams.aws.security import IdentityAndAccessManagementIam from diagrams.aws.devtools import Codebuild from diagrams.aws.devtools import Codecommit from diagrams.aws.devtools import Codedeploy from diagrams.aws.devtools import Codepipeline from diagrams.aws.management import Cloudformation from diagrams.aws.devtools import CommandLineInterface with Diagram("Serverless Web Apps", show=False, direction="TB"): with Cluster("CloudFormation"): cloudformation = Cloudformation("Stack") cloudformation >> IdentityAndAccessManagementIam("IAM") >> Codecommit( "CodeCommit") >> Codebuild("CodeBuild") >> S3( "S3") >> Codepipeline("CodePipeline") with Cluster("CodePipeline"): codepipeline = Codepipeline("Pipeline") codepipeline >> Codecommit("CodeCommit") >> Codebuild( "CodeBuild") >> Cloudformation("CloudFormation") with Cluster("Serverless Application Model"): sam = Cloudformation("SAM Template") sam >> APIGateway("API Gateway") >> Lambda("Lambda") >> DynamodbTable( "DynamoDB") cloudformation >> codepipeline >> sam
from diagrams import Diagram, Cluster from diagrams.aws.compute import ECS, AutoScaling from diagrams.aws.network import APIGateway, CloudMap with Diagram("AWS ECS Cluster", show=False, direction="TB"): api_gw = APIGateway("api gateway") with Cluster("vpc"): api_gw >> CloudMap("service discovery") >> ECS( "ecs cluster") >> AutoScaling("capacity provider")
builder = User("Builder") cli = CommandLineInterface("AWS CLI") builder >> cli with Cluster("CloudFormation"): cloudformation = Cloudformation("Stack") cloudformation >> IdentityAndAccessManagementIam("IAM") cloudformation >> Codecommit("CodeCommit") cloudformation >> Codebuild("CodeBuild") cloudformation >> Codepipeline("CodePipeline") cloudformation >> S3("S3") cli >> cloudformation with Cluster("CodePipeline"): codepipeline = Codepipeline("Pipeline") codepipeline >> Codecommit("CodeCommit") codepipeline >> Codebuild("CodeBuild") codepipeline >> Cloudformation("CloudFormation") with Cluster("Serverless Application Model"): sam = Cloudformation("SAM Template") apigateway = APIGateway("API Gateway") mylambda = Lambda("Lambda") ddb = DynamodbTable("DynamoDB") sam >> apigateway sam >> mylambda sam >> ddb cloudformation >> codepipeline >> sam console >> apigateway
from diagrams import Cluster, Diagram from diagrams.aws.compute import Lambda, Fargate from diagrams.aws.database import Dynamodb from diagrams.aws.integration import SQS, SNS, SF from diagrams.aws.network import APIGateway from diagrams.aws.storage import S3 from diagrams.aws.analytics import Kinesis, KinesisDataFirehose with Diagram("SNS Integration", direction="LR", show=False): apig = APIGateway("Producer (http post)") topic = SNS("Topic") with Cluster("Consumers"): consumers_l = [ Lambda("Consumer"), Lambda("Consumer"), Lambda("Consumer") ] apig >> topic consumers_l >> topic
from diagrams.aws.integration import SNS from diagrams.aws.management import Cloudwatch from diagrams.aws.network import APIGateway from diagrams.onprem.compute import Server from diagrams.onprem.client import User with Diagram("BLT Kata final container diagram", show=True): payment_gw = Server("Payment Gateway") customer = User("Customer") marketing = User("Marketing") with Cluster("System"): with Cluster("Promotions"): promotions_cms = ECS("CMS") promotions_gw = APIGateway("Promotions API") promotions_be = Lambda("Promotions BE") promotions_cms >> promotions_gw >> promotions_be with Cluster("In Store"): printer_fe = S3("Docket Printer Front-end") docket_printer = Server("Docket Printer") cashier = User("Cashier") store_fe = S3("Store Front-end") store_api = APIGateway("Store API") store_be = Lambda("Store BE") cashier >> Edge(label="Retrieve printed docket") >> docket_printer printer_fe >> docket_printer store_db = S3("Store DB") cashier >> store_fe >> store_api >> store_be >> store_db
from diagrams import Cluster, Diagram from diagrams.aws.compute import Lambda, Fargate from diagrams.aws.database import Dynamodb from diagrams.aws.integration import Eventbridge from diagrams.aws.network import APIGateway from diagrams.aws.storage import S3 with Diagram("Message Broker Refactored", show=False): with Cluster("Event Processors"): with Cluster("System C", direction="TB"): apig = APIGateway("webhook") handler = Lambda("handler") with Cluster("System D", direction="TB"): processor = Lambda("handler") ddb = Dynamodb("database") stream_listener = Lambda("processor") broker = Eventbridge("message broker") with Cluster("System B", direction="TB"): event_handler = Lambda("handler") bucket = S3("S3") file_processor = Lambda("processor") apig >> handler >> broker >> processor processor >> ddb >> stream_listener >> broker
from diagrams import Diagram from diagrams.aws.compute import Lambda, Batch, ECS, EKS, ElasticBeanstalk, Compute, AutoScaling, Fargate, Lightsail, SAR, ServerlessApplicationRepository from diagrams.aws.storage import S3, Backup, EBS, EFS, S3Glacier, Storage, StorageGateway from diagrams.aws.database import Dynamodb, RDS, Redshift, DB, ElastiCache, Neptune, Timestream from diagrams.aws.network import APIGateway, CloudFront, GlobalAccelerator, Route53, VPC from diagrams.aws.integration import Eventbridge, SNS, SQS, Appsync, StepFunctions from diagrams.aws.analytics import Kinesis, Athena, Quicksight, ES, ElasticsearchService, Analytics, DataPipeline, Glue, EMR, KinesisDataAnalytics, KinesisDataFirehose, KinesisDataStreams, LakeFormation, Redshift, ManagedStreamingForKafka from diagrams.aws.ml import Sagemaker, Comprehend, Rekognition, Forecast, Personalize, Polly, Textract, Transcribe, Translate, MachineLearning, Lex, SagemakerNotebook, SagemakerModel, SagemakerTrainingJob with Diagram("Event-based Application", show=False): eb = Eventbridge("EventBridge (Event Router)") apig = APIGateway("REST API") apig >> Lambda("API Handler(s)") >> Dynamodb("Data")
from diagrams import Diagram from diagrams.aws.network import APIGateway from diagrams.aws.compute import Lambda from diagrams.aws.database import Aurora with Diagram("Lambda Invocation", show=False): api_gw = APIGateway("API Gateway") my_lambda = Lambda("Lambda") my_db = Aurora("Aurora Database") api_gw >> my_lambda >> my_db
from diagrams import Cluster, Diagram from diagrams.aws.compute import Lambda, Fargate from diagrams.aws.database import Dynamodb from diagrams.aws.integration import SQS, SNS, SF from diagrams.aws.network import APIGateway from diagrams.aws.storage import S3 from diagrams.aws.analytics import Kinesis, KinesisDataFirehose with Diagram("Kinesis Integration", direction="LR", show=False): with Cluster("Sources"): producers_l = [APIGateway("Source"), Lambda("Source")] producers_r = [Lambda("Source"), Fargate("Source")] stream = Kinesis("Stream") producers_l >> stream producers_r >> stream stream >> Lambda("Sink")