Skip to content

Instantly share code, notes, and snippets.

@mauricioklein
Last active May 5, 2021 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricioklein/acc23474fafc8d3289a80d420ec630c7 to your computer and use it in GitHub Desktop.
Save mauricioklein/acc23474fafc8d3289a80d420ec630c7 to your computer and use it in GitHub Desktop.
CDK Debugging on VSCode

Install

Place launch.json file in .vscode/ directory in the root of your CDK application

It assumes the entry point of your CDK app is in bin/app.ts.

Adjust args attribute accordingly if you use something else.

Run

Use VSCode debug mode, running the Debug CDK configuration

Tested with CDK versions 1.89.0 and 1.101.0, so any version between those two should work just fine

{
"version": "0.2.0",
"configurations": [
{
"name": "Debug CDK",
"type": "node",
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"runtimeArgs": ["-r", "./node_modules/ts-node/register/transpile-only"],
"args": ["${workspaceFolder}/bin/app.ts"]
}
]
}
@kayuapi
Copy link

kayuapi commented May 5, 2021

if you have nvm installed, include
"runtimeVersion": "12.20.1" in configurations property of launch.json like below:
{
"version": "0.2.0",
"configurations": [

  {
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "skipFiles": [
      "<node_internals>/**"
  ],
  "runtimeVersion": "12.20.1",
  "runtimeArgs": [
      "-r", "./node_modules/ts-node/register/transpile-only"
  ],
  "args": [
      "${workspaceFolder}/bin/cdk-try.ts"
  ]
  }

]
}
ref: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_multi-version-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment