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:
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) {
pulumi.All(infos).ApplyT(
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
},
)
}