Diagrams
Diagrams is a Python library that allows users to draw cloud system architectures and other technical diagrams as code. It leverages Graphviz to render visual representations, enabling version-controlled, reproducible, and dynamic documentation for multi-cloud deployments (AWS, Azure, GCP, Kubernetes, etc.), on-premise solutions, and more. Currently at version 0.25.1, the library maintains an active release cadence with frequent updates adding new icons and features.
Warnings
- gotcha The `diagrams` Python package requires the Graphviz system-level tool to be installed on your operating system. Without Graphviz, diagrams cannot be rendered, and you will encounter errors. This is a common oversight.
- gotcha In version 0.25.1, the `pre-commit` development dependency was incorrectly included as a runtime dependency in the PyPI package. This means `pre-commit` and its transitive dependencies will be installed for all users of the library, increasing installation size and potentially causing conflicts.
- breaking Diagrams requires Python 3.9 or higher. Using it with older Python versions will result in compatibility errors.
Install
-
pip install diagrams -
brew install graphviz -
sudo apt-get install graphviz -
choco install graphviz
Imports
- Diagram
from diagrams import Diagram
- EC2
from diagrams.aws.compute import EC2
Quickstart
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.storage import S3
with Diagram("Simple Web Application", show=False, filename="simple_web_app"):
web_server = EC2("Web Server")
database = RDS("Database")
static_storage = S3("Static Content")
web_server >> database
web_server >> static_storage