I asked this before, but perhaps with too many wor...
# general
r
I asked this before, but perhaps with too many words (https://pulumi-community.slack.com/archives/C84L4E3N1/p1728048751497019): Is the
pulumi.output
meant to recursively to convert something like:
Copy code
{ foo: { bar: pulumi.Output<string>('baz} } }
to:
Copy code
pulumi.Output<object>({ foo: { bar: 'baz' } })
?
To answer my own question,
pulumi.output
does recursively flatten/lift nested outputs to a single outer
Output
across objects and arrays, however it specifically excludes `pulumi.Resource`s which halt the recursion: https://github.com/pulumi/pulumi/blob/d64448ec3b52cf5d4682a70e2f854c9736a86fd8/sdk/nodejs/output.ts#L447-L450
In my case I convinced myself with:
Copy code
export const svc = resources.apply((rs) =>
  pulumi
    .output(
      Object.values(rs).map((vs: any) => {
        delete vs['__pulumiResource'];
        return vs;
      }),
    )
    .apply((vs) => vs.filter((v: any) => v.kind === 'Service')),
);
which worked how I wanted after I stripped the nominal type marker property `__pulumiResource`(obviously a hack)
the comment in pulumi source code says:
Copy code
// Don't unwrap Resources, there are existing codepaths that return Resources through
// Outputs and we want to preserve them as is when flattening.
so I am wondering if there are existing code paths that would help me here... since I really do want to lift a field which is an
Output
so I can use it as part of a predicate in a filter