Skip to content

Instantly share code, notes, and snippets.

@lblackstone
Last active January 11, 2024 00:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lblackstone/e91e841cf022e67586aa98fb2c5025fe to your computer and use it in GitHub Desktop.
Save lblackstone/e91e841cf022e67586aa98fb2c5025fe to your computer and use it in GitHub Desktop.
Debugging provider plugin in a live Pulumi program
  1. Install dlv - https://github.com/go-delve/delve/tree/master/Documentation/installation
  2. Compile and link k8s provider with optimizations off - https://github.com/pulumi/pulumi-kubernetes/commit/3681117730a6440d89e697bc6ae46141fb965d8d (make build && make install && yarn link "@pulumi/kubernetes")
  3. Compile pulumi/pulumi with dlv WIP - https://github.com/pulumi/pulumi/commit/50414ca053981af7560b17df72a0251b9ac2ec03 (make build && make install)
  4. Run the dlv WIP pulumi binary (~/go/bin/pulumi up --logtostderr -v4 --logflow)
  5. Connect GoLand remote debugger to localhost:2345

Current Limitations:

  • Only works for k8s provider
  • Attaches to first launched process of the k8s provider
  • No first-class "debug mode" in pulumi bin; requires manual compilation
  • k8s provider make flags are not conditional
  • Program timeouts are still active
  • dlv doesn't always exit cleanly, requiring manual process cleanup (pkill dlv && pkill pulumi-resource-kubernetes && pkill pulumi-language-nodejs)
  • Only tested with GoLand on MacOS (should be possible to connect other programs to the headless dlv instance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment