Skip to content

jessicalynch/draws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

draws: lightweight AWS Diagram Automation

draws is a dependency-free tool for automating AWS architecture diagram creation.

Example AWS architecture diagram generated by draws from AppSync GraphQL DynamoDB template

Example AWS architecture diagram generated by draws from S3 trigger template

Example AWS architecture diagram generated by draws from serverless backend stack template

Install

pip install draws

Example Usage (from cdk app)

Add Diagrams.of(app) before app.synth().

app.py:

from aws_cdk import App

from draws import Diagrams
from infra.api_to_s3_stack import ApiToS3Stack
from infra.s3_bucket_stack import S3BucketStack

app = App()

bucket_stack = S3BucketStack(app, f"draws-dev-bucket", public_prefix="public")
docs_ui_stack = ApiToS3Stack(app, f"draws-dev-docs-ui", bucket=bucket_stack.bucket)

# Pass the cdk app into Diagrams.of() (directory defaults to app.py location)
Diagrams.of(app, directory="examples/output")

app.synth()

Run cdk ls to generate diagrams for each stack.

output:

$ cdk ls
Diagram saved to: examples/output/draws-dev-bucket.diagram.svg
Diagram saved to: examples/output/draws-dev-docs-ui.diagram.svg

Example Usage (from template)

import os
from pathlib import Path

from draws import Diagram


if __name__ == "__main__":
    curr_dir = Path(os.path.abspath(os.path.dirname(__file__)))
    templates_dir = curr_dir / "cdk.out"

    D = Diagram.from_template(
        filename=templates_dir / "my-stack.template.json",
        title="My AWS Stack",
    )

    D.to_svg()

Example Usage (manual)

import os
from pathlib import Path

from draws import Diagram, Elem


if __name__ == "__main__":
    with Diagram(title="My AWS Stack") as D:
        rest_api = Elem("AWS::ApiGateway::RestApi", "Rest API")
        lambda_func = Elem("AWS::Lambda::Function", "Lambda")
        bucket = Elem("AWS::S3::Bucket", "Bucket")

        rest_api >> lambda_func
        rest_api << lambda_func
        lambda_func >> bucket

        D.to_svg()

About

Lightweight AWS Diagram Automation

Resources

Stars

Watchers

Forks

Packages

No packages published