Debug Terraform (Azure Devops) Provider with VSCode


In an effort to save someone the pain of having to go through what I did when trying to get debugging to work on the Terraform Azure Devops Provider acceptance tests, here’s the solution.

Prior to starting I was already able to run, debug the unit tests and run the acceptance tests. This article is only about enabling debugging for terraform acceptance tests.

Update: Checkout the Issues section for how to enable codelens debugging.


The environment is also set up in the Azure Devops devcontainer. The code below can also be found in the repository.

Set up

Add the launch.json and .env below. Edit the .env file as needed for your terraform provider secrets.

NB: The buildFlags attribute was only needed for Azure Devops provider, for example, the Databricks provider work without it.

    "version": "0.2.0",
    "configurations": [
            "name": "Launch a test",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${file}",
            "args": [
            "env": {
                "TF_ACC": "1",
            "buildFlags": "-v -tags=all",
            "showLog": true,
            "envFile": "${workspaceFolder}/.env"



Make sure Launch a test is selected in the VSCode debug window

Launch debug

Debug a test

Highlight the name of the test you wish to run test in the test file and press F5 or select Start debugging.

Debugging in action

Run debug test


The only issue with this solution is that you have to highlight the test name and press F5 instead of being able to just select the debug test option above each test in VSCode. You’re able to run non-integration tests via that option and run all tests via the corresponding run test option.

Debug test

I’d love it if anyone could share a solution where they’ve got it to work with that.

Fixed: Enable codelens debugging

The missing piece to enable codelens debugging is to add the below flags to go.testFlags in settings.json


    "go.testFlags": [

Huge thanks to Thomas Meckel for figuring this out!


Inspired by