I came cross a nice Diagram as Code tool, it allows me to draw Cloud system architecture in Python code.
To use it, you need to install Graphviz and diagrams python module.
brew install graphviz
pip install diagrams
Here is a sample code of using the tool to create the diagram of AWS transit gateway network architecture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Diagram as code sample – TGW network | |
| """ | |
| from diagrams import Diagram, Edge | |
| from diagrams.aws.network import ( | |
| TransitGateway, | |
| VPC, | |
| VPCCustomerGateway, | |
| SiteToSiteVpn, | |
| DirectConnect, | |
| VPCCustomerGateway, | |
| ) | |
| from diagrams.aws.general import OfficeBuilding | |
| with Diagram("AWS TGW Network Infrastructure", show=False): | |
| tgw = TransitGateway("tgw") | |
| VPC("workload vpc 01") – tgw | |
| VPC("workload vpc 02") – tgw | |
| VPC("workload vpc 03") – tgw | |
| ( | |
| tgw | |
| – Edge(label="inter region peering") | |
| – TransitGateway("tgw") | |
| – VPC("workload vpc 04") | |
| ) | |
| tgw – VPC("shared service vpc") | |
| tgw – DirectConnect("direct connect") – OfficeBuilding("on-premise") | |
| tgw – SiteToSiteVpn("vpn connection") – VPCCustomerGateway("customer gateway") |
Run the script python tgw-diagram.py, then you will see the nice diagram 😉
