pistazie / cdk-dia

Automated diagrams of CDK provisioned infrastructure
MIT License
877 stars 37 forks source link

Feature Request: add granted resources and actions into diagram #9

Open dnltsk opened 3 years ago

dnltsk commented 3 years ago

Awesome tool 💪

Seems that imported resources aren't considered yet when generating the diagram.

For example, the following cdk code

Bucket.fromBucketName(this, 'my-bucket-import', 'my-bucket').grantRead(instance);

could -theoretically- be placed into the diagram that the Instance reads from the bucket. Currently not even the bucket is made it onto the diagram

Same for other imported resources like Topic, Queue, Table, ..

pistazie commented 3 years ago

tnx 🚀

As you said it looks like imported resources aren't diagramed.

This is tricky as cdk-dia diagrams according to the CDK Construct tree. In the Construct tree the imported bucket is represented as:

"my-bucket-import": {
            "id": "my-bucket",
            "path": "SoTsStack/my-bucket",
            "constructInfo": {
              "fqn": "@aws-cdk/core.Resource",
              "version": "1.102.0"
            }
          },

which provides no details about this being an imported resource and about its type (S3 Bucket).

Implementing this requires looking deeper into how CDK handles imports and figuring how can this be achieved.

Regarding showing in the diagram that this instance reads from the bucket, that's a great idea. I'll open it in another issue.