This message was deleted.
# typescript
s
This message was deleted.
b
g
Cool! So, how does it actually work? Doesn't look like self-explanatory to me. "to directory" - so what does it do? Render it to a yaml-file, not to a a string?
or
Output<string>
which I would prefer in this case
Maybe I'll just try it out 😁
Ah right, now I got it. I think this won't do it for me unfortunately
Guess I'll go via a route where I have a separate YAML file with some string keys which I'll replace via regexp in
.apply
for the `Output`s I need...
Not exactly pretty
s
You can construct a JavaScript object representing the structure you want, and serialise it once those outputs are known.
Strictly better than file templating.
g
@stocky-spoon-28903 yes, definitely. But how? I mean, it's trivial to generate YAML, but with
Output
objects involved it isn't anymore. Let's assume I have a longish data structure with tens of Outputs. The only way I can think of that this could be done is to list all of the Outputs in
pulumi.all
and then use that to apply the values at the same time and then return the result. To me this feels messy and hard to read. I would much prefer that I could just place the Output values directly into the data structure where they belong to and call a single function to evaluate it in such a way that all Outputs within it are realized. Then I could just serialize that to YAML without issues
I actually tried to do this. Take a data structure in, search for all Output objects, use those as pulumi.all parameters and then go replace the realized Output values in correct places in the data structure. Couldn't quite get it working and it was rather hard to debug so I kinda gave up
But that approach should work at least in theory
s
Copy code
const manifest = pulumi.output({
    key: valueThatIsOutput,
    nested: {
        key2: “prompt value”,
        key3: valueThatIsOutput
    },
}).apply(JSON.stringify)
You don’t need to reify each thing individually (it would be pretty unforgivable if you did need to do that and there wasn’t a runtime library function to do it!)
g
Hmm. I did try that obviously and that did not work
I was surprised and asked some help earlier here regarding it
Need to revisit this