Terraform Provider for Splunk ITSI
- install Terraform (>= v1.7): https://learn.hashicorp.com/tutorials/terraform/install-cli
- golang version 1.23 installed
- goreleaser: https://goreleaser.com/install/
It is important to start a provider in debug mode only when you intend to debug it, as its behavior will change in minor ways from normal operation of providers. The main differences are:
- Terraform will not start the provider process; it must be run manually.
- The provider's constraints will no longer be checked as part of terraform init.
- The provider will no longer be restarted once per walk of the Terraform graph; instead the same provider process will be reused until the command is completed.
Prerequisites:
- Go installed on your system
- GoLand is installed
Steps:
- Pass debug flag, It can be done via the Run Configuration:
- Make sure plugin is compiled in debug mode (
go build -gcflags="all=-N -l"
, GoLand takes care of this, executing via Debug button)
Prerequisites:
- Go installed on your system
- VS Code v1.74 installed on your computer
- Go is installed in your VS Code editor
Steps:
- create a .vscode dir in the root of your clone terraform-provider-splunk-itsi local repo then create a launch.json inside that .vscode directory.
$ cat << 'EOF' > terraform-provider-splunk-itsi/.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Provider",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"env": {"PKG_NAME": "${relativeFileDirname}"},
"args": [
"--debug",
],
"showLog": true,
}
]
}
EOF
- After launching the plugin will output a message telling you to set the TF_REATTACH_PROVIDERS environment variable:
- Copy and paste this to another shell, from which you will run Terraform:
- Observe your caught breakpoint: