How should we implement the WaitForState
or RetryContext
functionality in the new Terraform plugin framework.
We have a lot of long-running operations and we need to wait for the resource to be fully provisioned.
Thanks
How should we implement the WaitForState
or RetryContext
functionality in the new Terraform plugin framework.
We have a lot of long-running operations and we need to wait for the resource to be fully provisioned.
Thanks
Hi again @tiwood
These pieces of terraform-plugin-sdk helper/resource package functionality:
Do not have an equivalent implementation in terraform-plugin-framework. This exported functionality is actually not specific to terraform-plugin-sdk based code and can be used in terraform-plugin-framework based code (or really, any Go code) by importing the terraform-plugin-sdk package code as necessary.
It is not exactly clear at the moment whether these will be ever ported to the terraform-plugin-framework codebase, since its generic Go code to handle retries in a particular manner. There are likely community Go modules that implement similar functionality, but I have not personally done any particular discovery effort in this area. If there is nothing out there that is similar and “friendly” enough for provider development use cases, they could potentially be introduced as separate Go module(s).
I went ahead and created Document Outside Framework Migration Items (Retry, WaitForState, etc) · Issue #513 · hashicorp/terraform-plugin-framework · GitHub to ensure that the framework’s migration guide includes at least some mention of how to handle these. As part of that documentation effort when it occurs (or if there are good insights gained in this discussion!), we can decide how to best proceed.
Cheers.
Hello,
I personally find backoff package - github.com/cenkalti/backoff/v4 - Go Packages really great to do the job.
Cheers
Yann
Even after using github.com/cenkalti/backoff/v4 v4.1.3
, go compiler fails to compile the terraform provider.
$ go build
# github.com/hashicorp/terraform-plugin-framework/internal/proto6server
../../go/pkg/mod/github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/proto6server/serve.go:14:34: cannot use &Server{} (value of type *Server) as tfprotov6.ProviderServer value in variable declaration: *Server does not implement tfprotov6.ProviderServer (missing method CallFunction)
# github.com/hashicorp/terraform-plugin-framework/internal/proto5server
../../go/pkg/mod/github.com/hashicorp/terraform-plugin-framework@v1.4.2/internal/proto5server/serve.go:14:34: cannot use &Server{} (value of type *Server) as tfprotov5.ProviderServer value in variable declaration: *Server does not implement tfprotov5.ProviderServer (missing method CallFunction)
Here’s the provider’s go.mod
Hey @TheNilesh , it looks like you’re using
terraform-plugin-framework@v1.4.2
and terraform-plugin-go@v0.23.0
. You’ll want to upgrade your version of plugin-framework to v1.6.0
or later, see release notes for the plugin-go module.
The reason for that is terraform-plugin-framework
implements the provider server RPCs defined in an interface in terraform-plugin-go
. When we add new RPCs to terraform-plugin-go
(like the ones referenced here for provider defined functions) that are required to be implemented, you’ll get an implementation error if you upgrade one Go module without the other.
We typically call this out in the release notes of terraform-plugin-go
to describe the latest modules you need to be using to upgrade. The other Go modules (which I don’t see you using here) that also follow this are: terraform-plugin-sdk/v2
, terraform-plugin-mux
, terraform-plugin-testing
.