DEV Community


Posted on • Updated on

VSCode + Terraform Provider Development: Setup Debugging

Edit May 2022: This guide now reflects allowing resolution of the service via relative file paths. Previously you had to specify the service via environment variable PKG_NAME=<specific aws service>, now instead you set "env": {"PKG_NAME": "${relativeFileDirname}"} in launch.json and the service is automagically resolved. Thanks to @gdavison for solving this!

To setup debugging while writing to the AWS Terraform Provider, create a .vscode dir in the root of your clone terraform-provider-aws local repo then create a launch.json & private.env inside that .vscode directory.


$ git clone
$ mkdir terraform-provider-aws/.vscode
Enter fullscreen mode Exit fullscreen mode

Create launch.json

$ cat << 'EOF' > terraform-provider-aws/.vscode/launch.json
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit:
    "version": "0.2.0",
    "configurations": [
            "name": "Launch a test function",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "env": {"PKG_NAME": "${relativeFileDirname}"}, 
            "args": [
            "showLog": true,
            "envFile": "${workspaceFolder}/.vscode/private.env"
Enter fullscreen mode Exit fullscreen mode

Create private.env

$ cat << 'EOF' > terraform-provider-aws/.vscode/private.env
Enter fullscreen mode Exit fullscreen mode


Reload VSCode and source a profile for terraform's acc tests to use. You can do this by either opening vscode from a terminal with a profile set or by using the AWS Toolkit.

Set break-points in your <resource_name>.go file, highlight the test you want to run and click the green "play" button in VSCode debug panel (top left). Note: if you click any other play buttons, it may not work. It must be the debug pane play button that says "launch a function".

Image description


Discussion (2)

danquack profile image
Daniel Quackenbush

I recently used this to develop on the provider and it made it so much easier! Thank you.

drewmullen profile image
drewmullen Author

so glad it was helpful!