Hi team, I’m wondering what <registering resource ...
# general
Hi team, I’m wondering what registering resource outputs for a pulumi component does. It’s not too clear to me from documentation whether this is cosmetic or necessary for a pulumi component to be functional. If we have a
ctx.RegisterResourceOutputs(<component>, resourceOutputsMap)
at the end of our component’s constructor but before the return, will this call ensure that all values in
resolve before proceeding? I don’t see anything visual during
pulumi preview
when adding this call (just the usual exports). Any help in understanding this method would be appreciated, as I’m debating whether or not I should call it.
it's currently cosmetic, but you should call it as it lets the component know that all outputs have resolved
I see. Am I calling it the right way? I read about apply in Pulumi, but I wonder if the return in my first function could potentially execute before the apply callback in second function is executed (during resource provisioning). For reference, here’s my go code:
Copy code
func NewMyComponent(ctx *pulumi.Context, name string, opts …pulumi.ResourceOption) (*MyComponent, error) {
  // infos is a []pulumi.StringOutput in format "output_key1=output_value1;;;output_key2=output_value2…"
  addInfoToOutputs(ctx, myComponent, infos)

  return myComponent, nil

func addInfoToOutputs(ctx *pulumi.Context, myComponent *MyComponent, infos []pulumi.StringOutput) {
    func(args []interface{}) error {
      var outputs pulumi.Map
      for _, arg := range args {
        s := strings.Split(arg.(string), ;;;)
        for _, element := range s {
          pair := strings.Split(element, "=")
          if len(pair) != 2 {
            return errors.New(fmt.Sprintf("Expected computed output pair to be of length 2, but got length %v", len(pair)))
          outputs[pair[0]] = pulumi.String(pair[1])
      err := ctx.RegisterResourceOutputs(myComponent, outputs)
      if err != nil {
        return err
      return nil
I personally would not call that from a function, but that looks functionally correct yes
👍 1
Is there any feedback I should be able to see from
pulumi preview
letting me know that
actually ran?
not in preview no, preview doesn't know about outputs
Right makes sense. I guess that would only resolve after actual provisioning — thanks for your help 🙂
yeah, outputs only resolve once the cloud provider returns values
👍 1