cfn-diagram
cfn-diagram copied to clipboard
When pointing to --cdk-output with CDKv2 it throws an UnhandledPromiseRejectionWarning
Command: cfn-dia draw.io --cdk-output cdk.out --output-file $(sed "s/values/diagrams/g;s/.json/.drawio/g" <<< values/david-test.json) --ci-mode --skip-synth
Log:
[creatediagram] (node:73636) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'cdk.out/WAF-DAVID-INT-KY4K140S.assets.template.json' [creatediagram] at Object.openSync (fs.js:498:3) [creatediagram] at Object.readFileSync (fs.js:394:35) [creatediagram] at fromCDK (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:95:30) [creatediagram] at Object.get (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:31:16) [creatediagram] at Object.generate (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/graph/MxGenerator.js:243:41) [creatediagram] at Command.<anonymous> (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/commands/draw.io/index.js:37:23) [creatediagram] at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:922:31) [creatediagram] at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1503:14) [creatediagram] at Command._dispatchSubcommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1443:18) [creatediagram] at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1460:12) [creatediagram] (Use
node --trace-warnings ...to show where the warning was created) [creatediagram] (node:73636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) [creatediagram] (node:73636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Same here: I was trying to create a diagram for a stack based on CDK 2.3.0.
The error message I get is
(node:39447) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'cdk.out/my-stack-dev.assets.template.json'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at fromCDK (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:96:30)
at Object.get (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/shared/templateParser.js:31:16)
at Object.generate (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/graph/MxGenerator.js:243:41)
at Command.<anonymous> (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/commands/draw.io/index.js:37:23)
at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:922:31)
at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1503:14)
at Command._dispatchSubcommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1443:18)
at Command._parseCommand (/usr/local/lib/node_modules/@mhlabs/cfn-diagram/node_modules/commander/index.js:1460:12)
(node:39447) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:39447) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
In the cdk.out directory I have
cdk.out manifest.json my-stack-dev.assets.json my-stack-dev.template.json tree.json
you might workaround with something like cdk synth > template.yaml
and use the file as input like cfn-dia ... template.yaml
that works for cdk v2 as well but the names look weird
The same for me. From what I noticed you can just do cfn-dia d -t cdk.out/YOUR_STACK.template.json
and it will generate the diagram.
Sorry for the very late attention on this.
Can you please try to see if the latest release (1.1.34) fixes this. Leaving this open until I get thumbs up. Have tested with this CDK project and was able to reproduce the error and verified that the fix worked.
Still getting this issue, just updated to the latest build. I was using CDK pipelines. I temporarily commented the pipeline and directly put my stack in the /bin file, then it worked. Obviously this is not ideal because it means altering CDK (and what it's going to deploy) in order to generate a diagram.
It's a CDK pipeline that deploys 2 lambdas (a simple hello world and goodbye world) in 2 accounts, each in 2 regions. When I run the rool I get a similar error as above. After cdk synth I was able to give the template path from the various folders the cdk.out folder
@RachelleJanssen do you have a link to the project's repo?