Regardign dynamic providers, how do I wire the out...
# general
a
Regardign dynamic providers, how do I wire the outputs to appear in the resource member fields? I return an output in the corresponding provider functions but the member of the resource stays
undefined
Especially properties that I compute in
check
, how do I make them visible on the resource object?
e
This depends on which language your using?
a
typescript
e
So in your resource constructor you need to call super which looks something like:
Copy code
super(provider, name, args, opts);
args is normally an object coming in as a constructor parameter, but rather than passing that parameter straight through to
super
make a new object which has declares all the inputs (taking the value from
args
) and all the outputs but just setting them to undefined. Then pass that object to
super
. The runtime will then iterate that object and set properties on the resource itself based on the names. For typescript you'll also want to declare those properties in the resource class with something like:
Copy code
public readonly outputProperty: pulumi.Output<number>;
but those typings annotations aren't available at runtime for the framework to inspect, thus the args trickery.
a
Ah, I was missing the set them to undefined part and only passed in the inputs!
e
Yeh it's very non-obvious, we need better examples of this stuff.
As for
check
the result of that will be passed as the inputs for
create
or
update
, so if you want values from there in your final result just make you thread it through create/update from ins to outs.
a
Yes, thanks, I figured this out already (the hard way)
Yay, it works now 🥳
This has been more difficult than I expected to get right
e
Yeh dynamic providers started life as an internal trick for testing and then kinda grew into part of the public product, they really need some polish and love. I've got some cleanup ideas for them for 4.0