pistazie / cdk-dia

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

Relationships between stacks #17

Closed eikeon closed 2 years ago

eikeon commented 2 years ago

Love the tool so far.

One thing I noticed, is for my case, I'm not seeing any relationships between stacks. Looking at my cdk.out/tree.json many of them show up in the environment variables section of a lambda where the value is a Fn::ImportValue to another stack.

Assuming these are relationships the tool could chase down and draw?

Thank you for the tool!

pistazie commented 2 years ago

Tnx @eikeon, interesting feature

Been playing around with this but don't yet have a working solution.

There are a few options for implementation. one could diagram exports, their edge to the resources they export, and their usage as imports. I prefer skipping that and diagraming a direct edge between the originally exported resource and the resource using it in the other stack.

I will try and see how it works out soon.

eikeon commented 2 years ago

@pistazie, sounds great, in my use case I think the direct edge approach would work out well. Let me know if you want me to try out a branch or otherwise try and help

pistazie commented 2 years ago

Edge resolution between stacks (by Fn::Import and Exports) should now be in place. upgrade to 0.6.0

eikeon commented 2 years ago

Awesome; trying it out now

eikeon commented 2 years ago

For the few stacks I've tried so far am running into:

Failed to generate diagram - TypeError: Cannot read property 'stackExportsContainer' of undefined (node:29051) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'stackExportsContainer' of undefined at AwsEdgeResolver.findTargetComponent (/usr/local/lib/node_modules/cdk-dia/dist/src/diagram/aws/aws-edge-resolver.js:70:67)

pistazie commented 2 years ago

I published 0.6.1 to fix the above error. while I hope a diagram will now be created for your stacks I'm rather unsure there will be edges between the stacks.

If it doesn't work as expected could you please post the tree.json (found in the cdk.out folder) of one of the stacks? additionally the aws-cdk version could be helpful.

pistazie commented 2 years ago

@eikeon did you get a chance to try it out? another use asked about this feature at #19

eikeon commented 2 years ago

@pistazie I got a chance to upgrade to 0.6.1 and it's now generating a diagram again. I think it's now showing a few more of the relationships between stacks but not all. I'll send along a tree.json

robdmoore commented 2 years ago

Hey,

Would you expect that an S3 bucket that has a grantWrite to a lambda in a different stack should show the dependency? I've got that and it doesn't seem to show it. I'm in 0.6.1

pistazie commented 2 years ago

@robdmoore I am able to reproduce that. will check why the edge isn't generated.

robdmoore commented 2 years ago

Amazing thanks 🙌

On 24 Jan 2022, at 1:56 am, Tom @.***> wrote:

 @robdmoore I am able to reproduce that. will check why the edge isn't generated.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

pistazie commented 2 years ago

@robdmoore @eikeon - should now work in 0.7.0.

seems to work for a grantWrite() scenario as seen in https://github.com/pistazie/cdk-dia-test-fixture-apps/commit/85462d8fa3e6c27653d36fe0a1a7d86fff4aa94d