I am trying to port a new terraform provider to Pu...
# general
w
I am trying to port a new terraform provider to Pulumi using the pulumi-terraform bridge repo. I found the "updating Pulumi Providers" wiki page which is helpful. Is there a guide for starting a new Pulumi provider from terraform from scratch?
g
I believe https://github.com/pulumi/pulumi-tf-provider-boilerplate is what you're looking for.
w
oh yeah that looks right. How is this different from pulumi/pulumi-terraform?
looks like pulumi-terraform is a dependency — so i've been barking up the wrong tree 🙃
thanks Cameron
g
you're welcome!
Which provider are you looking at doing?
w
want to pair? 😁
s
@worried-engineer-33884 Is this a provider you built originally?
w
Hi James (thanks for merging my PR, another one inbound with a link to the boilerplate repo!)
No I am not involved in the terraform provider at all
s
The unfortunate thing is that it’s not really doing any kind of dependency pinning, which may cause problems updating in future
w
My client uses it for IPAM in conjunction with the AWS provider. We are looking at moving this to Pulumi—my mandate is to POC porting SOLIDServer terraform to Pulumi
s
OK - it doesn’t look like a particularly hard provider to port.
w
Right, it just leans on
go get
I think (I am not a go expert)
s
Right - so
go get
looks at the import paths and gets the latest version of each one
w
I can fork it and create a lock file if that's helpful
s
That’s fine for what it does, but can lead to a lot of churn - especially for the transitive dependencies of Terraform which are many and varied
That said, it might not present a huge problem.
Getting it to a POC should be straightforward - the second problem I spot in the repo is that the documentation is not in the standard upstream format (it’s just in the README), so doc comments won’t be generated properly.
w
got it — i think we can live without for this first pass
So, should I just start following the pulumi-tf-provider-boilerplate README and ping you if I get stuck?
s
Sure - that will work!
One thing worth verifying is that you can build one of the other terraform-backed providers in your development environment - that should ensure you have all the correct tools etc
w
should i skip the govendor-override step?
Yeah, it just errors out
so do i copy Gopkg.template.toml to Gopkg.toml manually, and then add the dependencies from terraform-provider-solidserver manually as "constraints"?
which i think is just a single dependency github.com/hashicorp/terraform/plugin
well, no, there's more i guess
Copy code
└──➤ go get -d -v
<http://github.com/alexissavin/terraform-provider-solidserver|github.com/alexissavin/terraform-provider-solidserver> (download)
<http://github.com/alexissavin/gorequest|github.com/alexissavin/gorequest> (download)
<http://github.com/moul/http2curl|github.com/moul/http2curl> (download)
<http://github.com/hashicorp/terraform|github.com/hashicorp/terraform> (download)
So just add these ☝️ ?
s
Sorry, was just grabbing coffee
Yes - I’d copy the template to be Gopkg.toml manually (and delete the template)
then all you need to do is just run
dep ensure -v
and it should produce a lock file with usable versions of things, assuming the repo is actually `go get`able
w
ok i tried that and it complained about the gorequest and http2curl dependencies
Copy code
Warning: the following project(s) have [[constraint]] stanzas in Gopkg.toml:

  ✗  <http://github.com/alexissavin/gorequest|github.com/alexissavin/gorequest>
  ✗  <http://github.com/moul/http2curl|github.com/moul/http2curl>

However, these projects are not direct dependencies of the current project:
so i removed them
s
Huh, what does the Gopkg.toml look like?
They likely don’t need to appear in there at all
w
now getting:
Copy code
Solving failure:
        (1) failed to list versions for <https://github.com/pulumi/pulumi-solidserver>: ERROR: Repository not found.
i must have messed up a search/replace
☝️ i commented out the two dependencies it was complaining about
i left hashicorp/terraform
and also the provider i am trying to port which is from the boilerplate
s
So I don’t think you need much of this
You should just need:
The underlying provider repo, pulumi and pulumi-terraform
Everything else should be inferred
w
Is the
resources.go
editing bit optional? Can I get away without it for now?
@stocky-spoon-28903 I've done everything up to the edit resources.go part. Would you mind taking a look at this PR? https://github.com/dustinfarris/pulumi-solidserver/pull/1
s
I can take a look shortly - en route to the airport right now
👍 1
w
awesome, thanks
s
Just took a quick look actually - it looks good so far!
w
Thanks for looking! Do I have to edit resources.go or can I get away without that part?
s
No, you need to map through each resource in the Terraform provider in resources.go
And assign it a pulumi-style name
w
ok got it. i'll start working on that now. is there a simpler example of this than pulumi-aws?
s
Yes! Almost anything else 🙂
Take a look at
pulumi-random
There’s a similar block for Data Sources too (but random doesnt have any): https://github.com/pulumi/pulumi-openstack/blob/master/resources.go#L306-L350 is a good example