https://pulumi.com logo
#contribute
Title
# contribute
s

stale-lamp-8682

01/05/2024, 8:05 PM
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

big-architect-71258

01/06/2024, 11:51 AM
@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

stale-lamp-8682

01/08/2024, 9:24 AM
Thank you for your answer. Do you know why there is no official way to do that?
b

big-architect-71258

01/08/2024, 9:36 AM
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

stale-lamp-8682

01/08/2024, 9:40 AM
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

big-architect-71258

01/08/2024, 9:41 AM
I always find it horrible to work with template repos. But that's a personal matter.
s

stale-lamp-8682

01/08/2024, 9:54 AM
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

big-architect-71258

01/08/2024, 10:07 AM
So, seems to work for you now. Any stuff that I could improve in the Cookiecutter template? I suspect the documentation 😄
s

stale-lamp-8682

01/08/2024, 10:09 AM
Just that:
b

big-architect-71258

01/08/2024, 10:10 AM
Almost impossible. Because for that the template has to analyze the GO AST. Don't think it's worth the effort.
s

stale-lamp-8682

01/08/2024, 10:10 AM
maybe in documentation
b

big-architect-71258

01/08/2024, 10:12 AM
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

stale-lamp-8682

01/08/2024, 10:13 AM
ok thank you 🙂 I’m a real beginner in pulumi
b

big-architect-71258

01/08/2024, 10:14 AM
Only for my personal records: how long did it take you to setup the Cilium provider with the Cookiecutter template?
s

stale-lamp-8682

01/08/2024, 10:15 AM
about 1 hour
b

big-architect-71258

01/08/2024, 10:17 AM
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

stale-lamp-8682

01/08/2024, 10:22 AM
I don’t know, i’m beginner in golang. I created only one serious project which is terraform provider 🙂
b

big-architect-71258

01/08/2024, 10:23 AM
Thanks for answering my question. Much appreciated!
s

stale-lamp-8682

01/08/2024, 10:27 AM
@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

big-architect-71258

01/08/2024, 11:12 AM