This guide outlines the process for setting up and performing live debugging of the Genesys Cloud Terraform Provider source code alongside Terraform Core. More information about debugging plugin providers can be found in the official docs.
- Go version 1.20.14 (recommended for the Genesys provider)
- Terraform Core
- Debugger: Delve
- Integrated Development Environment (IDE): Visual Studio Code or GoLand
- Sample
main.tf
file with theterraform
block configured to use the local provider for testing
-
Clone the source code:
git clone https://github.com/MyPureCloud/terraform-provider-genesyscloud
-
Install Go 1.20.14 from the Archived version list.
-
Set up your IDE (Visual Studio Code is used in this guide).
-
Create a
launch.json
file in VS Code with the following debug configuration:{ "version": "0.2.0", "configurations": [ { "name": "Debug Genesys Cloud Terraform Provider", "type": "go", "request": "launch", "mode": "debug", "program": "${workspaceFolder}", "env": {}, "args": ["--debug"] } ] }
-
Build the source code:
make build make sideload
-
In VS Code, select "Debug Genesys Cloud Terraform Provider" in the Debug view.
-
Start the debugger. This will load the source with the Delve debugger.
-
In the Debug Console, copy the
TF_REATTACH_PROVIDERS
environment variable line. -
Open a new terminal in VS Code and set the
TF_REATTACH_PROVIDERS
environment variable using the copied line. For example:$ export TF_REATTACH_PROVIDERS='{"genesys.com/mypurecloud/genesyscloud":{"Protocol":"grpc","ProtocolVersion":5,"Pid":94538,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/v2/vr8_wczj64q137jp1rrpvlz40000gp/T/plugin4151936511"}}}'
-
Set breakpoints in the desired files (e.g.,
resource_genesyscloud_routing_wrapupcode.go
). -
Run
terraform init
followed byterraform apply
in the terminal. -
The debugger will pause at the set breakpoints, allowing you to step through the code and inspect variables.
- Ensure that the
source
attribute in therequired_providers
block in yourmain.tf
file is set to"genesys.com/mypurecloud/genesyscloud"
- The
TF_REATTACH_PROVIDERS
environment variable enables debugging with breakpoints.
By following these steps, you can effectively debug the Genesys Cloud Terraform Provider in your development environment.
Documentation inspired by a blog post on the Developer Center