https://pulumi.com logo
Title
b

big-architect-71258

02/09/2023, 6:14 PM
@enough-garden-22763 just working on the support for PF in the Cookiecutter Pulumi Provider template. When I use the template to wrap the current Hashicorp TLS provider (branch master, because that's the only one using PF 1.1.1) and I try to generate
tfgen
via
make tfgen
, compilation fails with following error:
(cd provider && go build -o /tmp/pulumi-tls/bin/pulumi-tfgen-tls -ldflags "-X <http://github.com/pulumiverse/pulumi-tls/provider/pkg/version.Version=0.0.1-alpha.1675966033+870bfb04.dirty|github.com/pulumiverse/pulumi-tls/provider/pkg/version.Version=0.0.1-alpha.1675966033+870bfb04.dirty>" <http://github.com/pulumiverse/pulumi-tls/provider/cmd/pulumi-tfgen-tls)|github.com/pulumiverse/pulumi-tls/provider/cmd/pulumi-tfgen-tls)>
# <http://github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge|github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge>
/home/user/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.1.0/tfbridge/naming.go:33:44: undefined: tfgen.Renames
/home/user/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.1.0/tfbridge/provider.go:86:20: undefined: tfgen.Renames
Makefile:27: recipe for target 'tfgen' failed
Do I reference a wrong version of
pulumi-terraform-bridge/pf
? I didn't experience this error when I manually wrapped the MSSQL provider.
e

enough-garden-22763

02/09/2023, 6:16 PM
There's two go modules github.com/pulumi/pulumi-terraform-bridge/v3 and https://github.com/pulumi/pulumi-terraform-bridge/blob/master/pf/go.mod - please make sure both reference the same commit / version, then I think this should go away.
b

big-architect-71258

02/09/2023, 6:26 PM
Yup! That did the trick. Used an old version of
v3
. I guess that's the expected output if no resources has been mapped in the
resources.go
. Right?
Ouch! I mapped the missing resources using:
Resources: map[string]*tfbridge.ResourceInfo{
			"tls_cert_request": {
				Tok: tfbridge.MakeResource(mainPkg, mainMod, "CertRequest"),
			},
			"tls_locally_signed_cert": {
				Tok: tfbridge.MakeResource(mainPkg, mainMod, "LocallySignedCert"),
			},
			"tls_private_key": {
				Tok: tfbridge.MakeResource(mainPkg, mainMod, "PrivateKey"),
			},
			"tls_self_signed_cert": {
				Tok: tfbridge.MakeResource(mainPkg, mainMod, "SelfSignedCertificate"),
			},
But this caused this.
(cd provider && go build -o /tmp/pulumi-tls/bin/pulumi-tfgen-tls -ldflags "-X <http://github.com/pulumiverse/pulumi-tls/provider/pkg/version.Version=0.0.1-alpha.1675966948+616ad824.dirty|github.com/pulumiverse/pulumi-tls/provider/pkg/version.Version=0.0.1-alpha.1675966948+616ad824.dirty>" <http://github.com/pulumiverse/pulumi-tls/provider/cmd/pulumi-tfgen-tls)|github.com/pulumiverse/pulumi-tls/provider/cmd/pulumi-tfgen-tls)>
/tmp/pulumi-tls/bin/pulumi-tfgen-tls schema --out provider/cmd/pulumi-resource-tls
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0xecad1a]

goroutine 1 [running]:
<http://github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*ProviderInfo).SetAutonaming(0xc0007df7a0|github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*ProviderInfo).SetAutonaming(0xc0007df7a0>, 0xff, {0x27a37d0, 0x1})
        /home/user/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.39.3/pkg/tfbridge/provider.go:1389 +0xda
<http://github.com/pulumiverse/pulumi-tls/provider.Provider()|github.com/pulumiverse/pulumi-tls/provider.Provider()>
        /tmp/pulumi-tls/provider/resources.go:160 +0x8d1
main.main()
        /tmp/pulumi-tls/provider/cmd/pulumi-tfgen-tls/main.go:23 +0x2e
Makefile:27: recipe for target 'tfgen' failed
I'll investigate this any further tomorrow. If you have a quick idea what's causing this, this would be helpful of course šŸ‘šŸ¼
e

enough-garden-22763

02/09/2023, 6:51 PM
No quick thoughts here, we're missing a nil check and helpful error somewhere.
b

big-architect-71258

02/09/2023, 7:05 PM
I'll let you know tomorrow šŸ‘šŸ¼ about my findings
e

enough-garden-22763

02/09/2023, 11:07 PM
Is this trying to upgrade pulumi/pulumi-tls fork by any chance? I can get a working pulumi/pulumi-tls PR - was going to do that anyway soon-ish.
b

big-architect-71258

02/10/2023, 1:11 PM
Terraform TLS provider is my victim to test the new implementation of the Cookiecutter Template. Because it's in so many ways oddly setup, e.g. untile v3.4.0 the go.mod module does not match the source URL and it has not /v3 to match the used git tag etc etc.
e

enough-garden-22763

02/10/2023, 2:42 PM
That makes sense! In that case we're not duplicating work. We just picked it for dogfooding for similar reasons - so it will be one of the first ones to use the PF bridge under the hood in actual Pulumi providers (after pulumi-random).
b

big-architect-71258

02/10/2023, 3:16 PM
Quick note about the SIGSEGV from yesterday: I activated autonaming on the provider using
prov.SetAutonaming(255, "-")
. When I remove the statement
tfgen
sucessfully creates a
bridge-metadata.json
image.png
And I'm able to successfully create the SDKs.
Everything done via the Cookiecutter Template šŸ˜€
e

enough-garden-22763

02/10/2023, 5:07 PM
Excellent! Gotcha. I'll file an issue - I think this entire area needs to be revisited a bit since the PF bridge doesn't properly respect some of the ProviderInfo options, but it's not obvious yet through compile-time errors or warnings etc.
b

big-architect-71258

02/10/2023, 6:23 PM
I finished the (first) implementation to support the terraform-plugin-framework in the Cookiecutter Template for Pulumi Providers. https://github.com/tmeckel/pulumi-tf-provider-cookiecutter Perhaps you'll like to give it a try to scaffold the TLS provider (or a different one) šŸ˜€ I'd appreciate any feedback about the documentation and well the template worked for you! I succefully tested the template with the following terraform providers: • github.com/hashicorp/terraform-provider-tls • github.com/aiven/terraform-provider-aiven • github.com/civo/terraform-provider-civo • github.com/fortinetdev/terraform-provider-fortios • github.com/tmeckel/terraform-provider-mssql