https://pulumi.com logo
#golang
Title
# golang
b

brash-gigabyte-81569

10/27/2023, 4:24 PM
Are there any complex examples of using the
pulumi-go-provider
? I am having a soul crushing experience trying to get a component that outputs a complex type (eks.Cluster) from one component and then takes that complex type as an input into another component. Error is
2 UNKNOWN: failed to copy inputs for {...}: copying input "eksCluster": unmarshaling value: expected a eks.Cluster, got a string
when it goes to create the second component that makes use of the output. Related notes: the provider is written in go, the consumer is written in typescript, and consuming with yaml works fine.
a

ancient-policeman-24615

11/02/2023, 12:42 AM
Hey @brash-gigabyte-81569. I’m sorry to hear that. Just so I understand, your saying that: • You have written a component provider in go (using the
pulumi-go-provider
framework) • You can successfully consume the provider you wrote in Pulumi YAML. • You cannot consume the provider you wrote in typescript because you get an unmarshalling error. Does that sound right? I’d love to see a repro of this, since everything you described should be possible.
b

brash-gigabyte-81569

11/02/2023, 1:24 PM
that is correct
i am trying to build out a simple example but have been short on time lately ,once i get it done i can put the links here
related note, when i dump the variable the string is an urn
Let me know if you want to test anything
@ancient-policeman-24615 I am wondering if these changes that you are working on are related and if so if you would like me to test it out or anything.
a

ancient-policeman-24615

11/14/2023, 7:28 PM
Those changes are largely unrelated. Sorry for the extremely large response time. Last week was a hack week for us, and then I was on PTO. I’ll take a look at your example this week.
They do work in a similar area to where I think you are getting the area from, so they might turn out to be tangentially related.
b

brash-gigabyte-81569

11/14/2023, 7:32 PM
Yeah, that’s why I was curious ha. Anyway, thanks for taking a look, hopefully I am just doing something wrong that is an easy change.
I figured it out and it is quite a nuanced bug. Issue presents itself when I have Provider A returning a reference to a Provider B resource but the main stack doesn’t use any Provider B’s resources directly in the main stack, only through Provider A. For example, if I have a provider that returns an s3 bucket, and then pass that s3 bucket into another component in Provider A it will fail as the aws provider wasn’t registered in the main stack so it treats the urn as a string instead of rehydrating the reference. However, if I create some aws resource in the main stack it will work. I have a feeling there is some initialization code that sets up resource tracking for a provider that doesn’t happen when I don’t directly use it within the main stack.
a

ancient-policeman-24615

11/17/2023, 8:05 PM
That is some excellent sleuthing. Each generated SDK has a
RegisterResource
block: https://github.com/pulumi/pulumi-cloudflare/blob/cf179f8ec0138d1b2712d979f854a0e317ce826e/sdk/go/cloudflare/hostnameTlsSetting.go#L317-L325. That is the only thing I can think of that involves global initialization for deserialization.
b

brash-gigabyte-81569

11/17/2023, 8:08 PM
This code here made me think that the provider list was being provided from the main stack https://github.com/pulumi/pulumi/blob/master/sdk/nodejs/provider/server.ts#L319
Which has now lead me to how imports behave on TS. Looks like I can define my import as
import "@pulumi/aws";
instead of
import * as aws from "@pulumi/aws";
on the main stack and it will ensure that the provider is added without needing to create an aws resource directly
a

ancient-policeman-24615

11/17/2023, 8:52 PM
I opened https://github.com/pulumi/pulumi-go-provider/issues/157 to track this. I think this is an error in code generation. I’ll put it in front of the people who would know right now.
2 Views