victorious-ghost-35676
08/23/2022, 5:55 PMOutput<InputList<string>>
into a InputList<string>
The output is coming from a stack reference.bored-oyster-3147
08/23/2022, 6:06 PMOutput<InputList<string>>
? It shouldn't be coming from a stack reference like that, so did you do an .Apply(...)
to it?victorious-ghost-35676
08/23/2022, 6:11 PMdev
. But when I do the apply should it be something like Apply(x => x)
this give me an error, it does let me do a Apply(x => x.ToString())
bored-oyster-3147
08/23/2022, 6:17 PMApply(...)
function is meant to be used so checkout this blog post: https://leebriggs.co.uk/blog/2021/05/09/pulumi-apply
To be clear, .Apply(x => x);
is a no-op and doesn't do anything. The delegate that you pass to apply is meant to be used to transform the output of the eventual result, so if you are returning the same output you aren't doing any transformation. If you have an Output<string> output
and you do var newOutput = output.Apply(x => x);
than newOutput
will still be Output<string>
. However, if you do var newOutput = output.Apply(x => int.Parse(x))
than you will have converted the Output<string>
to an Output<int>
. Note that it is still an output. You cannot get the inner value out of the output.
If you have an Output<string[]>
or an Output<string>[]
or an Output<IEnumerable<string>>
, any of these can be implicitly cast to InputList<string>
without you needing to do anything. Outputs are meant to be able to be passed as inputs out of the box.victorious-ghost-35676
08/23/2022, 6:26 PMStackRefProdUsers = (InputList<string>)Users
bored-oyster-3147
08/23/2022, 6:27 PMStackRefProdUsers
is or what Users
is so it is hard to answer thatimplicit
cast, and you are doing an explicit
cast in that example. So drop the explicit cast, and allow the compiler to tell you whether or not your instance can be cast to the input.victorious-ghost-35676
08/23/2022, 6:30 PMCannot convert source type 'Pulumi.Output<object?>' to target type 'Pulumi.InputList<string>'
bored-oyster-3147
08/23/2022, 6:31 PMOutput<object?>
so you need to do an .Apply(...)
where the delegate does some type checking and transformation until you get something like an Output<List<string>>
that can be cast to InputList<string>
victorious-ghost-35676
08/23/2022, 6:51 PM