Are dynamic provider outputs just broken right now? I couldn't find a GitHub issue but I found some ...
l
Are dynamic provider outputs just broken right now? I couldn't find a GitHub issue but I found some Slack chats that seem to indicate something is borked. When I say dynamic provider outputs I mean like if you specify additional outputs of a dynamic provider resource separate from the inputs, then those outputs never show up.
Inputs that get passed through to outputs are fine, but just state outputs don't work. Minimal example:
Copy code
import * as pulumi from "@pulumi/pulumi";

const myProvider: pulumi.dynamic.ResourceProvider = {
  async create(inputs) {
    return {
      id: "foo",
      outs: {
        ...inputs,
        thiswontshowup: "this won't show up",
      }
    }
  }
}

type MyResourceInputs = { thisworksfine: pulumi.Input<string> };

class MyResource extends pulumi.dynamic.Resource {
  public readonly thiswontshowup!: pulumi.Output<string>;

  constructor(name: string, props: MyResourceInputs, opts?: pulumi.CustomResourceOptions) {
    super(myProvider, name, props, opts);
  }
}

export const myResource = new MyResource("test", {
  thisworksfine: "this works fine",
});

export const diditshowup = myResource.thiswontshowup ?? false;
pulumi preview
Outputs section:
Copy code
Outputs:
    diditshowup: false
    myResource : {
        @isPulumiResource: true
        id               : [unknown]
        thisworksfine    : "this works fine"
        urn              : "urn:pulumi:dev::pulumi-dynamic-rip::pulumi-nodejs:dynamic:Resource::test"
    }
As far as I can tell the state is updated, but something is going wrong between the state getting updated and
pulumi.dynamic.Resource
.
l
Have you missed a step?
Component resources can define their own output properties. Outputs in a component must be registered with the Pulumi IaC engine by calling registerOutputs.
https://www.pulumi.com/docs/iac/concepts/components/#registering-component-outputs
l
Hmm well this is for a dynamic resource and not a component resource, so
this.registerOutputs
doesn't even exist. I'm also not sure what the value would be set to since that comes from the dynamic provider.
l
I mean, inside the resource constructor. Not the provider code itself.
l
Yeah, that method is only in
pulumi.ComponentResource
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/classes/ComponentResource.html#registerOutputs which is not in the inheritance hierarchy for
pulumi.dynamic.Resource
.
pulumi.dynamic.Resource
inherits from
pulumi.CustomResource
which does not have that method. https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/classes/CustomResource.html
l
Fair enough, then you didn't miss a step 🙂 The code you posted and the reference code in the docs line up nicely, so it does look like some amount of borkage is happening.
l
The outputs seem to be making it into the state, but the deserialization in the nodejs SDK seems to not be handling it correctly for some reason. I haven't gotten much farther than that yet.
l
This might be the gotcha of you need to set "dummy inputs" for outputs you expect to come out later on
So e.g. if you have a state output
foo
, you do something like
this.foo = undefined
in the constructor
Because somewhere in the SDK I think Pulumi enumerates the inputs to determine outputs (not ideal but various historic reasons this is the case)
✅ 1
I think there's an issue for this; will try and dig it out
https://github.com/pulumi/docs/issues/1375 might link to the relevant things, maybe
l
@lively-crayon-44649 bingo! Adding placeholder props as done in that issue fixed it. It seems that using
this.foo = undefined
didn't do it so I guess it only looks at the props passed to the constructor somehow.
✅ 1