Terraform
- Plugin Framework
- v1.16.x (latest)
- No versions of this document exist before v1.15.x. Click below to redirect to the version homepage.
- v1.15.x
- v1.14.x
- v1.13.x
- v1.12.x
- v1.11.x
- v1.10.x
- v1.9.x
- v1.8.x
- v1.7.x
- v1.6.x
- v1.5.x
- v1.4.x
- v1.3.x
- v1.2.x
- v1.1.x
- v1.0.x
- v0.17.x
- v0.16.x
- v0.15.x
- v0.14.x
- v0.13.x
- v0.12.x
- v0.11.x
- v0.10.x
- v0.9.x
- v0.7.x
Debugging Framework Providers
This page contains implementation details for inspecting runtime information of a Terraform provider developed with Framework via a debugger tool. Review the top level Debugging page for information pertaining to the overall Terraform provider debugging process and other inspection options, such as log-based debugging.
Code Implementation
Update the main function for the project to conditionally enable the providerserver/ServeOpts.Debug field. Conventionally, a -debug flag is used to control the Debug value.
This example uses a -debug flag to enable debugging, otherwise starting the provider normally:
func main() {
    var debug bool
    flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
    flag.Parse()
    opts := providerserver.ServeOpts{
        Address: "registry.terraform.io/example-namespace/example",
        Debug:   debug,
    }
    err := providerserver.Serve(context.Background(), provider.New(), opts)
    if err != nil {
        log.Fatal(err.Error())
    }
}