https://pulumi.com logo
#package-authoring
Title
# package-authoring
d

dry-potato-52542

06/05/2023, 6:54 PM
Hey folks, I have question regarding Pulumi Bridge for Terraform Plugin Framework. There is one behavioral I can't explain and I am not totally sure if it's bug or I am doing something wrong. So I have a few data source, There is no input. They using your identity baked in into profile to retrive data. And all work fine of tf side., but when same data provider gets generate in pulumi I do observer a diff between them and another data sources. First of all they hav only gat method. Usually any data sorce will have regular call and wrapped into with pulumi like
getResource
and
getResourceOutput
Those data source also throwing this error:
Copy code
panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1b6c6e8]
    goroutine 25 [running]:
    <http://github.com/pulumi/pulumi-terraform-bridge/pf/internal/convert.(*encoding).NewDataSourceEncoder(0xc0003713a0|github.com/pulumi/pulumi-terraform-bridge/pf/internal/convert.(*encoding).NewDataSourceEncoder(0xc0003713a0>, {0xc0003b0408, 0x16}, {0xc000d50e10, 0x0, {0x0, 0x0, 0x0}})
    	/root/.cache/gomodcache/github.com/pulumi/pulumi-terraform-bridge/pf@v0.8.1/internal/convert/encoding.go:96 +0x88
    <http://github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge.(*provider).datasourceHandle(0xc00046d600|github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge.(*provider).datasourceHandle(0xc00046d600>, {0x38679d0, 0xc000d50de0}, {0xc0003b0408, 0x16})
    	/root/.cache/gomodcache/github.com/pulumi/pulumi-terraform-bridge/pf@v0.8.1/tfbridge/provider_datasources.go:53 +0x1eb
    <http://github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge.(*provider).InvokeWithContext(0xc00046d600|github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge.(*provider).InvokeWithContext(0xc00046d600>, {0x38679d0?, 0xc000d50c60?}, {0xc0003b0408, 0x16}, 0x2dc013d8?)
    	/root/.cache/gomodcache/github.com/pulumi/pulumi-terraform-bridge/pf@v0.8.1/tfbridge/provider_invoke.go:41 +0x176
    <http://github.com/pulumi/pulumi-terraform-bridge/pf/internal/plugin.(*providerServer).Invoke(0xc000bb32f0|github.com/pulumi/pulumi-terraform-bridge/pf/internal/plugin.(*providerServer).Invoke(0xc000bb32f0>, {0x38679d0, 0xc000d50c60}, 0xc00047ef00)
    	/root/.cache/gomodcache/github.com/pulumi/pulumi-terraform-bridge/pf@v0.8.1/internal/plugin/provider_server.go:505 +0x11d
    <http://github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler.func1({0x38679d0|github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler.func1({0x38679d0>, 0xc000d50c60}, {0x2f69500?, 0xc00047ef00})
    	/root/.cache/gomodcache/github.com/pulumi/pulumi/sdk/v3@v3.69.0/proto/go/provider_grpc.pb.go:480 +0x7b
    <http://github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x38679d0|github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0x38679d0>, 0xc000d50a20}, {0x2f69500, 0xc00047ef00}, 0xc000472940, 0xc000421aa0)
    	/root/.cache/gomodcache/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x3e8
    <http://github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler({0x30eff40|github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler({0x30eff40>?, 0xc000bb32f0}, {0x38679d0, 0xc000d50a20}, 0xc0008475e0, 0xc00078c080)
    	/root/.cache/gomodcache/github.com/pulumi/pulumi/sdk/v3@v3.69.0/proto/go/provider_grpc.pb.go:482 +0x138
    <http://google.golang.org/grpc.(*Server).processUnaryRPC(0xc0009905a0|google.golang.org/grpc.(*Server).processUnaryRPC(0xc0009905a0>, {0x3872ca0, 0xc000baa9c0}, 0xc000c1cc60, 0xc000bb3380, 0x4b4d0a0, 0x0)
    	/root/.cache/gomodcache/google.golang.org/grpc@v1.54.0/server.go:1345 +0xdf3
    <http://google.golang.org/grpc.(*Server).handleStream(0xc0009905a0|google.golang.org/grpc.(*Server).handleStream(0xc0009905a0>, {0x3872ca0, 0xc000baa9c0}, 0xc000c1cc60, 0x0)
    	/root/.cache/gomodcache/google.golang.org/grpc@v1.54.0/server.go:1722 +0xa36
    <http://google.golang.org/grpc.(*Server).serveStreams.func1.2()|google.golang.org/grpc.(*Server).serveStreams.func1.2()>
    	/root/.cache/gomodcache/google.golang.org/grpc@v1.54.0/server.go:966 +0x98
    created by <http://google.golang.org/grpc.(*Server).serveStreams.func1|google.golang.org/grpc.(*Server).serveStreams.func1>
    	/root/.cache/gomodcache/google.golang.org/grpc@v1.54.0/server.go:964 +0x28a
I have tries to upgrade to the latest version of the bridge, but this gives me following:
Copy code
# <http://github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge|github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge>
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/detect_check_failures.go:45:23: undefined: tfbridge.MiscFailure
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/detect_check_failures.go:47:23: undefined: tfbridge.MissingKey
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/detect_check_failures.go:50:23: undefined: tfbridge.InvalidKey
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/detect_check_failures.go:64:17: undefined: tfbridge.NewCheckFailure
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/detect_check_failures.go:72:17: undefined: tfbridge.CheckFailurePath
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/detect_check_failures.go:81:16: undefined: tfbridge.NewCheckFailurePath
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/provider_checkconfig.go:147:19: undefined: tfbridge.NewCheckFailurePath
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/provider_checkconfig.go:149:29: undefined: tfbridge.NewCheckFailure
../../../go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/pf@v0.11.0/tfbridge/provider_checkconfig.go:150:14: undefined: tfbridge.InvalidKey
make: *** [tfgen] Error 1
b

big-architect-71258

06/05/2023, 8:24 PM
@dry-potato-52542 how's your `go.mod`looking? Versions of Pulumi SDK and Terraform Bridge must be aligned carefully.
e

enough-garden-22763

06/05/2023, 8:24 PM
Hmm the latter message might be fixed if you upgrade https://github.com/pulumi/pulumi-terraform-bridge/v3 to v3.49.0
b

big-architect-71258

06/05/2023, 8:25 PM
@dry-potato-52542 do you have a public repo where the people from Pulumi might have a look?
e

enough-garden-22763

06/05/2023, 8:25 PM
For the former message I'd love a repro - we'd love to fix that, panics are prioritized easily
b

big-architect-71258

06/05/2023, 8:26 PM
@enough-garden-22763 I just upgraded to v0.11.0 and my go.mod file for the mssql provider ended up like he following
Copy code
<http://github.com/PGSSoft/terraform-provider-mssql/shim|github.com/PGSSoft/terraform-provider-mssql/shim> v0.0.0-00010101000000-000000000000
	<http://github.com/ettle/strcase|github.com/ettle/strcase> v0.1.1
	<http://github.com/pulumi/pulumi-terraform-bridge/pf|github.com/pulumi/pulumi-terraform-bridge/pf> v0.11.0
	<http://github.com/pulumi/pulumi-terraform-bridge/v3|github.com/pulumi/pulumi-terraform-bridge/v3> v3.48.1-0.20230605131955-5a0a54720def
	<http://github.com/pulumi/pulumi/sdk/v3|github.com/pulumi/pulumi/sdk/v3> v3.69.0
d

dry-potato-52542

06/05/2023, 8:26 PM
Copy code
<http://github.com/hashicorp/terraform-plugin-framework|github.com/hashicorp/terraform-plugin-framework> v1.2.0
	<http://github.com/pulumi/pulumi-terraform-bridge/pf|github.com/pulumi/pulumi-terraform-bridge/pf> v0.11.0
	<http://github.com/pulumi/pulumi-terraform-bridge/v3|github.com/pulumi/pulumi-terraform-bridge/v3> v3.48.1-0.20230527113951-a0f92e793f31
e

enough-garden-22763

06/05/2023, 8:27 PM
Good call, looks like I need to push an update to our go.mod; the
replace
directives fool us thinking that the tests work while breaking for the end-users
b

big-architect-71258

06/05/2023, 8:28 PM
@dry-potato-52542 what's the version of the Pulumi SDK?
b

big-architect-71258

06/05/2023, 8:32 PM
@enough-garden-22763 should I upgrade the PF version as well for the MSSQL provider? I suspect you'll release v0.12.0 based on the fix in the PR you posted.
e

enough-garden-22763

06/05/2023, 8:35 PM
Yeah it might land tomorrow, may be 0.11.1 if no new features
d

dry-potato-52542

06/05/2023, 8:59 PM
@enough-garden-22763 @big-architect-71258 I have upgraded to the latest version and seems like it's fixed all issue. Thanks
e

enough-garden-22763

06/05/2023, 9:01 PM
That's great news Andrii! Did the
panic: runtime error: invalid memory address or nil pointer dereference
also get solved? Thanks
Just making sure
d

dry-potato-52542

06/05/2023, 9:01 PM
Yes they are.
e

enough-garden-22763

06/05/2023, 9:01 PM
Perfect!
d

dry-potato-52542

06/05/2023, 9:01 PM
last thing - Usually any data sorce will have regular call and wrapped into with pulumi like
getResource
and
getResourceOutput
Functionally they technically the same but are there is way to generate Output version as well?
i have noticed this is happening when data source as such does not required properties
Copy code
data "mysource" {}
Anything I can do on my side to mitigate this? I get around by adding deprecated property 🙂 But this isn't the right approach.
e

enough-garden-22763

06/05/2023, 9:08 PM
Can you elaborate a bit? Yes I think usually Pulumi generates getSomethingOutput() form but is that not working for you?
d

dry-potato-52542

06/05/2023, 9:10 PM
Correct. For a resource where all properties are
Computed
i do not see
getSomethingOutput
being generated for some reason.
And that's not just one data source. It applies to all
e

enough-garden-22763

06/05/2023, 9:14 PM
Interesting, I'll have a look tomorrow
d

dry-potato-52542

06/05/2023, 9:14 PM
Thanks.
e

enough-garden-22763

06/06/2023, 7:39 PM
I think this is coming from the decision here https://github.com/pulumi/pulumi/blob/2f3e1657eb37b6c0980765a4e0055e5655b35c0d/pkg/codegen/schema/schema.go#L565 which is not currently configurable
Which language are you working in? TypeScript, Python, Go?
d

dry-potato-52542

06/06/2023, 7:39 PM
TypeScript
e

enough-garden-22763

06/06/2023, 7:40 PM
Ah perfect. Let me check something in TypeScript, one sec
d

dry-potato-52542

06/06/2023, 7:42 PM
Thanks.
e

enough-garden-22763

06/06/2023, 7:44 PM
So yes, in TypeScript you can manually promote a Promise result to an Output result. I'm using a quick AWS example here although this function (getGroup) does have an output version:
Copy code
export const n: pulumi.Output<aws.iam.GetGroupResult> = pulumi.output(aws.iam.getGroup({groupName: "my-group"}));
So you can use some workaround like this for now.
d

dry-potato-52542

06/06/2023, 7:44 PM
ok got it.
e

enough-garden-22763

06/06/2023, 7:44 PM
I think we could ask to introduce a switch to generate these output versions anyway
It's going to be a bit difficult to enable it by default as Pulumi has to tradeoff size of generated code vs convenience
Some of our packages are way too large and adding any functions at all is a cost
But perhaps an option that you can opt in for your provider to generate this Output versioned invoke anyway in this case, we could consider adding that.
Let me sketch out an issue.
d

dry-potato-52542

06/06/2023, 7:45 PM
Sure. Thanks for looking into it.
e

enough-garden-22763

06/06/2023, 7:51 PM
Please upvote, this helps it get prioritized
d

dry-potato-52542

06/06/2023, 7:54 PM
Done. Thanks.
16 Views