In the process of building Terraform custom provider using terraform-plugin-framework
. After updating bunch of dependencies, hit the following snag:
> make build
env GOOS=`uname | tr '[:upper:]' '[:lower:]'` GOARCH=amd64 GO111MODULE=on go build -o terraform-provider-core_v3.0.0_x1 -gcflags="all=-N -l" -ldflags "-X=main.Version=3.0.0 -X=main.Build=1"
# github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/provider.go:508:9: cannot use NewGRPCProviderServer(p) (value of type *GRPCProviderServer) as tfprotov5.ProviderServer value in return statement: *GRPCProviderServer does not implement tfprotov5.ProviderServer (missing method GetMetadata)
make: *** [build] Error 1
Since I'm using Terraform Framework (instead of SDK), this reference should not even be there terraform-plugin-sdk/v2/helper/schema/provider.go
I tried removing ./vendor
directory and downloading all packages from scratch, but the issue still persists. Appreciate any help.
Finally found the solution for this issue. Apparently this happened due to Go dependency super weird situation, for more details see this framework issue.
And the way it gets resolved by manually updating version of github.com/hashicorp/terraform-plugin-sdk/v2
package in go.mod
to set as v2.30.0
like so
go 1.19
require (
...
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
...
)
Keep in mind, if you try to build the code right after manual version update of the package, it'll fail agin:
env GOOS=`uname | tr '[:upper:]' '[:lower:]'` GOARCH=amd64 GO111MODULE=on go build -o terraform-provider-core_v3.0.0_x1 -gcflags="all=-N -l" -ldflags "-X=main.Version=3.0.0 -X=main.Build=1"
go: inconsistent vendoring in /Users/iamuser/terraform-provider-core:
github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/apparentlymart/go-textseg/v15@v15.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/hashicorp/hcl/v2@v2.19.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/zclconf/go-cty@v1.14.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
golang.org/x/crypto@v0.15.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
golang.org/x/sys@v0.14.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
golang.org/x/text@v0.14.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
google.golang.org/grpc@v1.57.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
github.com/apparentlymart/go-textseg/v13@v13.0.0: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
github.com/hashicorp/hcl/v2@v2.16.2: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.0: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
github.com/zclconf/go-cty@v1.13.1: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
golang.org/x/crypto@v0.14.0: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
golang.org/x/sys@v0.13.0: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
golang.org/x/text@v0.13.0: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
google.golang.org/grpc@v1.57.0: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
To ignore the vendor directory, use -mod=readonly or -mod=mod.
To sync the vendor directory, run:
go mod vendor
make: *** [build] Error 1
So, first thing you need to run is go mod vendor
to properly update dependancies, and then, you can build the code.
Hope this helps anyone who encounters such issue.