Anddd7 / diagrams-ext

:art: Extend the Diagrams with useful features, Diagram as Code for prototyping cloud system architectures
https://diagrams.mingrammer.com
MIT License
7 stars 1 forks source link

๐Ÿš€ feature: add cluster icon #1

Closed Anddd7 closed 10 months ago

Anddd7 commented 10 months ago

Add the icon as part of label in cluster, to visualize the 'VPC' type resources.

Origin PR: https://github.com/mingrammer/diagrams/pull/853 Others:

Demo:

with Diagram("demo", show=False):
    with Cluster("vpc", icon_node=VPC):
        igw = InternetGateway()

        with Cluster("public", icon_node=PublicSubnet):
            nat = NATGateway()
            elb = ElasticLoadBalancing()
        with Cluster("private", icon_node=PrivateSubnet):
            eks = EKS()
        with Cluster("intra", icon_node=PrivateSubnet):
            rds = RDSInstance()

        igw >> elb >> eks >> rds
        eks >> nat >> igw

demo

JobaDiniz commented 8 months ago

is this in the latest package? I don't see this option on the Cluster.

UPDATE: found it https://github.com/Anddd7/diagrams-ext/releases/tag/0.23.5-alpha3

JobaDiniz commented 8 months ago

What about using Custom for icons on the Cluster?

Anddd7 commented 8 months ago

is this in the latest package? I don't see this option on the Cluster.

UPDATE: found it https://github.com/Anddd7/diagrams-ext/releases/tag/0.23.5-alpha3

To make it easier to use, i rename it to diagrams-ext and uploaded to pypi, you can download it pip install diagrams-ext.

with Cluster("your-vpc", icon_node=VPC):
  ...

Another way is, I supposed this feature will be merged in upstream oneday๐Ÿ™‚, so i don't want to add some customized features here. So i create another repo: https://github.com/Anddd7/diagrams-patterns

I packaged some common component, like private/public subnet, region as cluster, you can check the example https://github.com/Anddd7/diagrams-patterns/blob/main/poc_aws_complex.py

Anddd7 commented 8 months ago

What about using Custom for icons on the Cluster?

I modified to code to accept string path directly, icon_node: Union[Type["Node"], str] = None,


oops, i just tried, url is not working, absolute path can.

 with Cluster("your-vpc", icon_node="/path/to/image.png"):

:fire: got error

 with Cluster("your-vpc", icon_node="https://img.icons8.com/ios-filled/50/share-3.png"):