Lightweight AWS Diagram Automation
Project description
draws: lightweight AWS Diagram Automation
draws is a dependency-free tool for automating AWS architecture diagram creation.
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
draws-1.0.0a3.tar.gz
(390.6 kB
view hashes)
Built Distribution
draws-1.0.0a3-py3-none-any.whl
(534.8 kB
view hashes)