Skip to content

Commit

Permalink
Add vscode debugging to troubleshooting guide (#11998)
Browse files Browse the repository at this point in the history
* adding vscode debugging

* adding vscode debugging

* Update troubleshooting.md

* removing SDK debug section for now, as not all these work

* troys feedback

---------

Co-authored-by: Troy Howard <[email protected]>
  • Loading branch information
interurban and thoward authored Jun 7, 2024
1 parent 27e216a commit 01d49d7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions content/docs/support/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ meta_image: /images/docs/meta-images/docs-meta.png
menu:
support:
weight: 1
search:
keywords:
- debugging pulumi programs

aliases:
- /docs/reference/troubleshooting/
Expand Down Expand Up @@ -51,6 +54,43 @@ Diagnostic logging can also be controlled with flags and environment variables o
$ TF_LOG=TRACE pulumi up --logtostderr --logflow -v=10 2> out.txt
```

## Attaching a debugger to a Pulumi program

When developing or troubleshooting Pulumi programs, you may need to debug your code. This example walks you through starting a Node.js debugging session in VS Code and setting breakpoints.

### Create VS Code launch configuration

In your project directory, create or update `.vscode/launch.json` with the following configuration to enable debugging:

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Pulumi Program (debug)",
"type": "node",
"request": "attach",
"continueOnAttach": true,
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"${workspaceFolder}/lib/**/*.js",
"<node_internals>/**/*.js"
]
}
]
}
```

### Set breakpoints and start Pulumi in debug mode

Open your program and set breakpoints by clicking in the gutter next to the line numbers.

In a terminal run `NODE_OPTIONS=”--inspect-brk” pulumi up` to start the deployment process in debug mode. This will cause Pulumi to pause execution and wait for a debugger to attach.

Press `F5` in VS Code to start debugging. VS Code will attach to the waiting Node.js process, and execution will continue until reaching the first breakpoint you have set.

For a step-by-step guide for attaching a debugger to a Pulumi program, check out this [blog on breakpoint debugging.](/blog/next-level-iac-breakpoint-debugging/)

## Performance

If you are seeing unexpectedly slow performance, you can gather a trace to understand what
Expand Down

0 comments on commit 01d49d7

Please sign in to comment.