pistazie / cdk-dia

Automated diagrams of CDK provisioned infrastructure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use cdk dia decorator on python project

robertofd1995 opened this issue · comments

First of all thanks for your time on this project, it's awesome.

I would like to be able to uncollapse in the diagram the nestedStacks that I have, I would like to understand why this feature is not available on other languages rather than js/ts.

My project is on python, and even thought the laguage doesn't have the concept of interface, with jsii it can be used in the following way

from constructs import Construct
import jsii
from aws_cdk import (
    NestedStack,
    aws_ec2 as ec2,
    aws_iam as iam,
    IInspectable
)

@jsii.implements(IInspectable)
class NetworkStack(NestedStack):

    @jsii.member(jsii_name="inspect")
    def inspect(self, inspector: "TreeInspector") -> None:
        """
        :param inspector:
        :return:
        """
        # add here the logic of cdkDiaDecorator
       pass

I am unfamiliar with how to compile ts to other languages, but why is not possible to export also the logic of that decorator to other languages?

Kind regards

Hi Reberto,

I guess it's not available because I didn't know how to do it :) but maybe you can help figure this out.

The basic thing here is that for customizing specific constructs CDK-Dia needs the data on the construct tree as attributes.CDK-DIA_CollapssingCustomizer:"FORCE_NON_COLLAPSE" (see example construct tree).

So if you can get CDK to add that attribute to the tree on synth-time your CDK-Dia will pick that up.

I guess you need then to adapt the code here to Python and replace it in the de inspect method above.

It would be even better if one could use jsii to use the already provided decorator so the Python way to customize will be the same as the TS way.