Hello, i tried to convert a terraform provider (<h...
# contribute
s
Hello, i tried to convert a terraform provider (https://github.com/littlejo/terraform-provider-cilium/) into pulumi provider. I used https://github.com/pulumi/pulumi-tf-provider-boilerplate. But when i do make tfgen, i have:
Copy code
make tfgen
 [ -x /usr/local/bin/pulumi ] || curl -fsSL <https://get.pulumi.com|https://get.pulumi.com> | sh
 pulumi plugin install resource random 4.3.1
 (cd provider && go build -o /Users/joseph.ligier/clients/perso/pulumi-cilium/bin/pulumi-tfgen-cilium -ldflags "-X <http://github.com/littlejo/pulumi-cilium/provider/pkg/version.Version=0.0.1-alpha.1704462644+44c4b661.dirty|github.com/littlejo/pulumi-cilium/provider/pkg/version.Version=0.0.1-alpha.1704462644+44c4b661.dirty>" <http://github.com/littlejo/pulumi-cilium/provider/cmd/pulumi-tfgen-cilium)|github.com/littlejo/pulumi-cilium/provider/cmd/pulumi-tfgen-cilium)>
# <http://github.com/littlejo/pulumi-cilium/provider|github.com/littlejo/pulumi-cilium/provider>
Copy code
./resources.go:62:25: cannot use cilium.New(version.Version)() (value of type "<http://github.com/hashicorp/terraform-plugin-framework/provider|github.com/hashicorp/terraform-plugin-framework/provider>".Provider) as *"<http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema|github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema>".Provider value in argument to shimv2.NewProvider
 make: *** [tfgen] Error 1
What did i miss? 🙂
b
@stale-lamp-8682 The TF Provider is using the Terraform Plugin Framework. The boilerplate repo is preconfigured for Terraform Providers using Terraform SDK v2. Perhaps you wanna use my Cookiecutter Template. It's able to autoconfigure the project correctly. https://github.com/tmeckel/pulumi-tf-provider-cookiecutter In addition you can use `make generate`to automatically create the resource and data source mappings required by
tfgen
.
s
Thank you for your answer. Do you know why there is no official way to do that?
b
First off, it's simply a question of how resources are allocated in a company and how much priority is assigned to a topic. Secondly: what do you mean by "official"? More documentation in the boilerplate repo? Some sort of "wizard" like my Cookiecutter template?
s
official means a repo with pulumi organization 🙂
[10/24] provider_github_organization (pulumiverse):
i don’t know what to answer i let like that? edit: ok it’s my github repo organization :)
b
I always find it horrible to work with template repos. But that's a personal matter.
s
Copy code
make tfgen
[ -x /usr/local/bin/pulumi ] || curl -fsSL <https://get.pulumi.com> | sh
pulumi plugin install resource random 4.3.1
(cd provider && go build -o /Users/joseph.ligier/pulumi-cilium/bin/pulumi-tfgen-cilium -ldflags "-X github.com/littlejo/pulumi-cilium/provider/pkg/version.Version=0.0.1-alpha.1704707222+7b9e912e" github.com/littlejo/pulumi-cilium/provider/cmd/pulumi-tfgen-cilium)
# github.com/littlejo/pulumi-cilium/provider
./resources.go:30:2: "github.com/littlejo/terraform-provider-cilium/cilium" imported as provider and not used
./resources.go:72:23: undefined: cilium
make: *** [tfgen] Error 1
Ok i add cilium to import and replace: > p := pf.ShimProvider(cilium.NewProvider()) By : > p := pf.ShimProvider(cilium.New(version.Version)())
Copy code
make generate
go generate provider/resources.go
🧱 Building tfgen ...
✨ Missing resource cilium
✨ Missing resource cilium_clustermesh
✨ Missing resource cilium_clustermesh_connection
✨ Missing resource cilium_config
✨ Missing resource cilium_hubble
✨ Missing resource cilium_kubeproxy_free
✨ Missing data source cilium_helm_values
🎯 Adding missing resources and data sources ...
🚀 Formatting code ...
b
So, seems to work for you now. Any stuff that I could improve in the Cookiecutter template? I suspect the documentation 😄
s
Just that:
b
Almost impossible. Because for that the template has to analyze the GO AST. Don't think it's worth the effort.
s
maybe in documentation
b
Small tip: to test the new provider it's the easiest to use a Pulumi YAML program because YAML only requires the provider it the local $PATH. No requirement for a complete setup for a program language SDK .
s
ok thank you 🙂 I’m a real beginner in pulumi
b
Only for my personal records: how long did it take you to setup the Cilium provider with the Cookiecutter template?
s
about 1 hour
b
If you don't mind: aside that you're a newbie with Pulumi what's your proficiency level in GO 1-10? I would like to estimate which group of people use the template.
s
I don’t know, i’m beginner in golang. I created only one serious project which is terraform provider 🙂
b
Thanks for answering my question. Much appreciated!
s
@big-architect-71258 https://github.com/littlejo/pulumi-cilium/actions/runs/7446056508
Copy code
- 1.21.x

  publish_sdk:
    name: Publish SDKs
    runs-on: ubuntu-latest
    needs: publish_binary
b