Hi All. I am trying to rebuild one of my pulumi pr...
# package-authoring
a
Hi All. I am trying to rebuild one of my pulumi providers that is brieded to my Terraform provider; however, when executing the make tfgen or make build_sdks, I am receiving the following error below:
Copy code
make tfgen
[ -x /opt/homebrew/bin/pulumi ] || curl -fsSL <https://get.pulumi.com> | sh
pulumi plugin install resource random 4.8.2
(cd provider && go build  -o /Users/wguilherme/go/src/github.com/zscaler/pulumi-zpa/bin/pulumi-tfgen-zpa -ldflags "-X <http://github.com/zscaler/pulumi-zpa/provider/pkg/version.Version=0.0.1-alpha.1707113237+ddbd1aa8.dirty|github.com/zscaler/pulumi-zpa/provider/pkg/version.Version=0.0.1-alpha.1707113237+ddbd1aa8.dirty>" <http://github.com/zscaler/pulumi-zpa/provider/cmd/pulumi-tfgen-zpa)|github.com/zscaler/pulumi-zpa/provider/cmd/pulumi-tfgen-zpa)>
# <http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema|github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema>
../../../../../pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230710100801-03a71d0fca3d/helper/schema/provider.go:511: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: *** [tfgen] Error 1
➜ pulumi-zpa (master) ✗ make build_sdks
[ -x /opt/homebrew/bin/pulumi ] || curl -fsSL <https://get.pulumi.com> | sh
pulumi plugin install resource random 4.8.2
(cd provider && go build  -o /Users/wguilherme/go/src/github.com/zscaler/pulumi-zpa/bin/pulumi-tfgen-zpa -ldflags "-X <http://github.com/zscaler/pulumi-zpa/provider/pkg/version.Version=0.0.1-alpha.1707113237+ddbd1aa8.dirty|github.com/zscaler/pulumi-zpa/provider/pkg/version.Version=0.0.1-alpha.1707113237+ddbd1aa8.dirty>" <http://github.com/zscaler/pulumi-zpa/provider/cmd/pulumi-tfgen-zpa)|github.com/zscaler/pulumi-zpa/provider/cmd/pulumi-tfgen-zpa)>
# <http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema|github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema>
../../../../../pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230710100801-03a71d0fca3d/helper/schema/provider.go:511: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: *** [tfgen] Error 1
How can I correct this problem? Thank you
b
@acoustic-tiger-77630 Perhaps you'd give my Cookiecutter Template https://github.com/tmeckel/pulumi-tf-provider-cookiecutter a try to wrap your provider. I wrapped the Zscaler ZPA provider (figured that you wanted to wrap this provider from the error you provided) and it worked like a charm (screenshot). The only thing I'd to change was
zpa.Provider()
to
zpa.ZPAProvider()
in
resources.go
. To get the documentation correctly you need the code of the Terraform Provider git cloned to the
upstream
directory. To automate this you can add the following lines to
Makefile
Copy code
PULUMI_REPO_PATHS:= <http://github.com/<repo-of-provider>=$(ROOT_DIR)/upstream|github.com/<repo-of-provider>=$(ROOT_DIR)/upstream>
upstream/.git:
        @echo "Initializing upstream" ; \
        git clone  --depth 1 --branch <version-of-the-provider> <https://github.com/><repo-of-provider> upstream
tfgen:: install_plugins upstream/.git
As I'm writing this I think I should add this to the template 😄
@acoustic-tiger-77630 small correction. If you add
TFProviderModuleVersion: "v3",
to
resources.go
just after
GitHubOrg:
tfgen
is able to resolve the provider repo and thus create the documentation.
a
Hey @big-architect-71258 Thank you for that. Much appreciated. I completely missed this. 🥴 I work at Zscaler, and we are working to officially re-publish and support the provider for both ZPA and ZIA in the next few weeks. Either way, I just tried by updating the resource.go file to v3 and I still get the same issue
Copy code
make tfgen
[ -x /opt/homebrew/bin/pulumi ] || curl -fsSL <https://get.pulumi.com> | sh
pulumi plugin install resource random 4.8.2
(cd provider && go build  -o /Users/wguilherme/go/src/github.com/zscaler/pulumi-zpa/bin/pulumi-tfgen-zpa -ldflags "-X <http://github.com/zscaler/pulumi-zpa/provider/pkg/version.Version=0.0.1-alpha.1707113237+ddbd1aa8.dirty|github.com/zscaler/pulumi-zpa/provider/pkg/version.Version=0.0.1-alpha.1707113237+ddbd1aa8.dirty>" <http://github.com/zscaler/pulumi-zpa/provider/cmd/pulumi-tfgen-zpa)|github.com/zscaler/pulumi-zpa/provider/cmd/pulumi-tfgen-zpa)>
# <http://github.com/pulumi/pulumi/pkg/v3/resource/deploy/deploytest|github.com/pulumi/pulumi/pkg/v3/resource/deploy/deploytest>
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/deploytest/languageruntime.go:59:58: undefined: plugin.ProgInfo
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/deploytest/languageruntime.go:109:14: undefined: plugin.ProgInfo
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/deploytest/pluginhost.go:293:9: cannot use &pluginHost{…} (value of type *pluginHost) as plugin.Host value in return statement: *pluginHost does not implement plugin.Host (wrong type for method LanguageRuntime)
		have LanguageRuntime(string, string, string, map[string]interface{}) (plugin.LanguageRuntime, error)
		want LanguageRuntime(string, plugin.ProgramInfo) (plugin.LanguageRuntime, error)
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/deploytest/pluginhost.go:334:35: cannot use host (variable of type *pluginHost) as plugin.Host value in argument to best.loadWithHost: *pluginHost does not implement plugin.Host (wrong type for method LanguageRuntime)
		have LanguageRuntime(string, string, string, map[string]interface{}) (plugin.LanguageRuntime, error)
		want LanguageRuntime(string, plugin.ProgramInfo) (plugin.LanguageRuntime, error)
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/deploytest/pluginhost.go:503:56: undefined: plugin.ProgInfo
# <http://github.com/pulumi/pulumi/pkg/v3/resource/deploy|github.com/pulumi/pulumi/pkg/v3/resource/deploy>
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/source_eval.go:225:104: too many arguments in call to iter.src.plugctx.Host.LanguageRuntime
	have (string, string, string, map[string]interface{})
	want (string, plugin.ProgramInfo)
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/source_eval.go:237:5: unknown field Program in struct literal of type plugin.RunInfo
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/source_query.go:145:87: too many arguments in call to src.plugctx.Host.LanguageRuntime
	have (string, string, string, map[string]interface{})
	want (string, plugin.ProgramInfo)
../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v3@v3.103.1/resource/deploy/source_query.go:172:3: unknown field Program in struct literal of type plugin.RunInfo
# <http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema|github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema>
../../../../../pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20230710100801-03a71d0fca3d/helper/schema/provider.go:511: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: *** [tfgen] Error 1
b
@acoustic-tiger-77630 you have to replace the current code with the code the Cookiecutter Template will create. The hints that I wrote in my answer relate completely to a wrapped provider repo created with the template.
In addition I saw that, at least for the DotNet SDK, you nee some special treatment because with the default mapping of the upstream Terraform resources and data sources you can compile the dotnet SDK because a resource collides with a namespace.
Copy code
/tmp/pulumi-zpa/sdk/dotnet/Ba/Certificate.cs(26,31): error CS0542: 'Certificate': member names cannot be the same as their enclosing type [/tmp/pulumi-zpa/sdk/dotnet/Pulumiverse.Zpa.csproj]
/tmp/pulumi-zpa/sdk/dotnet/CloudBrowserIsolation/Banner.cs(17,29): error CS0542: 'Banner': member names cannot be the same as their enclosing type [/tmp/pulumi-zpa/sdk/dotnet/Pulumiverse.Zpa.csproj]
Furthermore, because the ZPA and ZIA providers contain a large number of resources and data sources and in order to ensure that the generated SDKs are easily accessible by distributing the Terrafrom resources and data sources into the namespaces of the supported programming languages, it is important to study the output of `make build_sdks`and map resources and data sources differently if necessary.
a
I see. I am assuming that that I should be using your https://github.com/tmeckel/pulumi-tf-provider-cookiecutter instead of the traditional boilerplate provided by Pulumi. then.
b
Yep , that's right! 🙂
One side node: how to build and publish the wrapped provider is described in
README-DEVELOPMENT.md
in the created repository.
a
Thanks Thomas. I just used the cookiecutter and it’s very straightforward. Thanks for doing that. One thing though is that I got a couple errors here
Copy code
Provider module <http://github.com/zscaler/terraform-provider-zpa/v3|github.com/zscaler/terraform-provider-zpa/v3> diverges from provider source <https://github.com/zscaler/terraform-provider-zpa>
go: -replace=<http://github.com/zscaler/terraform-provider-zpa/v3=https://github.com/zscaler/terraform-provider-zpa@v3.1.0|github.com/zscaler/terraform-provider-zpa/v3=https://github.com/zscaler/terraform-provider-zpa@v3.1.0>: invalid new path: malformed import path "<https://github.com/zscaler/terraform-provider-zpa>": double slash
go: added <http://github.com/pulumi/pulumi-terraform-bridge/v3|github.com/pulumi/pulumi-terraform-bridge/v3> v3.73.0
go: downloading <http://github.com/pulumi/pulumi|github.com/pulumi/pulumi> v3.104.2+incompatible
go: downloading <http://github.com/pulumi/terraform-plugin-sdk/v2|github.com/pulumi/terraform-plugin-sdk/v2> v2.0.0-20240129205329-74776a5cd5f9
<http://github.com/zscaler/pulumi-zpa/provider|github.com/zscaler/pulumi-zpa/provider> imports
	<http://github.com/zscaler/terraform-provider-zpa/v3/https://github.com/zscaler/terraform-provider-zpa/blob/master/zpa/provider.go|github.com/zscaler/terraform-provider-zpa/v3/https://github.com/zscaler/terraform-provider-zpa/blob/master/zpa/provider.go>: malformed import path "<http://github.com/zscaler/terraform-provider-zpa/v3/https://github.com/zscaler/terraform-provider-zpa/blob/master/zpa/provider.go|github.com/zscaler/terraform-provider-zpa/v3/https://github.com/zscaler/terraform-provider-zpa/blob/master/zpa/provider.go>": double slash
Initialized empty Git repository in /Users/wguilherme/go/src/github.com/zscaler/pulumi-providers/pulumi-tf-provider-cookiecutter/pulumi-zpa/.git/
[main (root-commit) e84c8a9] Initial Commit.
I guess I should I have used slashes when providing the repo address
b
Seems you didn't get the go.mod
module
string right. The ZPA Provider is using
/v3
. These are my settings
Copy code
"terraform_provider_name": "zpa",
    "terraform_provider_org": "zscaler",
    "terraform_provider_source": "github.com/zscaler/terraform-provider-zpa",
    "terraform_provider_version_or_commit": "3.1.0",
    "terraform_provider_module": "github.com/zscaler/terraform-provider-zpa/v3",
    "terraform_provider_package_name": "zpa",
    "terraform_sdk_version": "2",
Cookiecutter has a replay function. Simply edit the
vi ~/.cookiecutter_replay/pulumi-tf-provider-cookiecutter.json
and change the settings and call
cookiecutter -f --replay gh:tmeckel/pulumi-tf-provider-cookiecutter
s
@acoustic-tiger-77630 Looks like Thomas has already gotten you up and going (thank you Thomas!), but if you have additional questions about bridging a provider feel free to reach out. The folks on my team (the Community Engineering team) might be able to help---although, to be honest, Thomas is amazing and you probably won’t need us for anything! 😄