I thought it would be good to see the article "Draw a system configuration diagram in Python using Diagrams | Developers.IO", but Python I didn't have an environment, so I tried it with Docker.
Official documentation says "Install diagrams
with pip
, also install Graphviz
. So create a Dockerfile accordingly.
Dockerfile
FROM python:latest
WORKDIR /app
RUN apt update && \
apt install -y python3-pygraphviz && \
pip install diagrams
Build. Keep a Docker image named diagrams
for easy execution later.
$ docker build -t diagrams .
This completes the creation of the diagrams: latest
Docker image.
Prepare the Official Quickstart file.
diagram.py
from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB
with Diagram("Web Service", show=False):
ELB("lb") >> EC2("web") >> RDS("userdb")
It's fairly intuitive, but see the official documentation for more details. Official document English but easy to read because it is simple and small in volume. Also, Examples is easy to understand.
According to the official documentation, if you have a local Python environment, you can run it with $ python diagram.py
.
Since we are using a Docker container this time, it is OK if we volume mount the current directory where diagram.py
is created and execute the command python diagram.py
.
Currently the current directory looks like this.
$ ls
Dockerfile diagram.py
Run the container.
$ docker run --rm -v `pwd`:/app diagrams python diagram.py
Another ls
will generate a png
file.
$ ls
Dockerfile diagram.py web_service.png
Check the contents of web_service.png
.
$ open web_service.png
The result is as per the official Quick Start!
I was able to easily try Diagrams using Docker. I tried Examples and made a configuration diagram as I wanted to make, but all I can say is "It can be managed by code", "Simple and easy to see", and "There are a lot of Nodes (like icons)". On the other hand, as for itching, when it gets complicated, it may be like "Node placement is not there!", And it seems that you can not write a Cluster that straddles Cluster, so "Apply the same security group to different AZ instances. I felt that it was difficult to express something like.
Either way, I think it's worth a try.
References -Draw a system configuration diagram in Python using Diagrams | Developers.IO
Recommended Posts