https://pulumi.com logo
#general
Title
# general
w

worried-engineer-33884

02/22/2019, 6:47 PM
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

gentle-diamond-70147

02/22/2019, 6:50 PM
I believe https://github.com/pulumi/pulumi-tf-provider-boilerplate is what you're looking for.
w

worried-engineer-33884

02/22/2019, 6:51 PM
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

gentle-diamond-70147

02/22/2019, 6:55 PM
you're welcome!
Which provider are you looking at doing?
w

worried-engineer-33884

02/22/2019, 6:57 PM
want to pair? 😁
s

stocky-spoon-28903

02/22/2019, 6:58 PM
@worried-engineer-33884 Is this a provider you built originally?
w

worried-engineer-33884

02/22/2019, 6:58 PM
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

stocky-spoon-28903

02/22/2019, 7:00 PM
The unfortunate thing is that it’s not really doing any kind of dependency pinning, which may cause problems updating in future
w

worried-engineer-33884

02/22/2019, 7:00 PM
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

stocky-spoon-28903

02/22/2019, 7:00 PM
OK - it doesn’t look like a particularly hard provider to port.
w

worried-engineer-33884

02/22/2019, 7:00 PM
Right, it just leans on
go get
I think (I am not a go expert)
s

stocky-spoon-28903

02/22/2019, 7:00 PM
Right - so
go get
looks at the import paths and gets the latest version of each one
w

worried-engineer-33884

02/22/2019, 7:00 PM
I can fork it and create a lock file if that's helpful
s

stocky-spoon-28903

02/22/2019, 7:01 PM
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

worried-engineer-33884

02/22/2019, 7:04 PM
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

stocky-spoon-28903

02/22/2019, 7:11 PM
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

worried-engineer-33884

02/22/2019, 7:26 PM
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

stocky-spoon-28903

02/22/2019, 7:47 PM
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

worried-engineer-33884

02/22/2019, 7:48 PM
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

stocky-spoon-28903

02/22/2019, 7:49 PM
Huh, what does the Gopkg.toml look like?
They likely don’t need to appear in there at all
w

worried-engineer-33884

02/22/2019, 7:50 PM
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

stocky-spoon-28903

02/22/2019, 8:04 PM
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

worried-engineer-33884

02/22/2019, 8:34 PM
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

stocky-spoon-28903

02/22/2019, 8:39 PM
I can take a look shortly - en route to the airport right now
👍 1
w

worried-engineer-33884

02/22/2019, 8:39 PM
awesome, thanks
s

stocky-spoon-28903

02/22/2019, 8:40 PM
Just took a quick look actually - it looks good so far!
w

worried-engineer-33884

02/22/2019, 9:15 PM
Thanks for looking! Do I have to edit resources.go or can I get away without that part?
s

stocky-spoon-28903

02/22/2019, 10:53 PM
No, you need to map through each resource in the Terraform provider in resources.go
And assign it a pulumi-style name
w

worried-engineer-33884

02/22/2019, 10:55 PM
ok got it. i'll start working on that now. is there a simpler example of this than pulumi-aws?
s

stocky-spoon-28903

02/22/2019, 11:09 PM
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