https://pulumi.com logo
Title
e

echoing-rain-5741

07/06/2020, 2:48 PM
Hi guys! I’m having some trouble understanding the difference between a
pulumi.Output
and a
Pulumi.OutputState
. I’m creating a config file ( in the form of a
pulumi.StringMap
) that includes various references to other pulumi resources, hence I used the
pulumi.All(arg1, arg2,...).ApplyT(func(args []interface{}) (pulumi.StringMap,error){...})
(as suggested in the docs,) which supposedly returns a
pulumi.Output
To be able to use it to create a kubernetes ConfigMap, i need to have a OutputState. What would the best way be to convert the output to the output state be, and what is the difference? I managed to convert the
pulumi.Output
config to a output state using
configMapData.Apply(func(x interface{}) (interface{}, error) { return x, nil }).OutputState
but this seems overly convoluted.
w

white-balloon-205

07/07/2020, 1:44 AM
To be able to use it to create a Kubernetes ConfigMap, I need to have an OutputState
This should not be the case. You should be able to use an Output as an input to a ConfigMap. In general, you shouldn’t need to work with OutputState directly unless you are building your own new kinds of Outputs. Could you share the ConfigMap code perhaps?
e

echoing-rain-5741

07/07/2020, 8:57 AM
Alright, thanks for your answer! After reading through the documentation of
ApplyT
, I understod that you can just cast the return value to a corresponding “registered” type. In my case i was returning a
pulumi.StringMap
, which apearantly doesn’t have a
pulumi.StringMapOutput
registered as its output type. If I return a
map[string]string
however, I’m able to cast the return value to a
pulumi.StringMapOutput
which
kubernetes.ConfigMapArgs
accepts. Is there any list of types with registered output types?
l

lemon-agent-27707

07/07/2020, 2:06 PM
You should never need to return a "pulumi type" from within an apply. Returning the raw value (string, int, or in this case map) is the way to go.
👍 1