any suggestions?
# general
e
any suggestions?
w
There’s some documentation on how to work with Outputs at https://pulumi.io/reference/programming-model.html#outputs. In your case you will want something like:
Copy code
pulumi.all([o1,o2]).apply(([o1val, o2val]) => JSON.stringify({ something: o1val, other: o2val });
Oh - and to the point about “not on preview” - you can use
Pulumi.runtime.isDryRun
to check whether it is a preview and only write the file to disk if it’s not.
e
i've got a small issue, which is the object i'm trying to stringify already exists, and i'm just trying to replace some properties
w
Then same as above - but write the values into the object inside the apply instead of using them to construct a new object.
e
ok, cool, thanks. i'm gonna give that a try
ok. i've got some progress, but still getting complains about the output
let me show you a specific example
Copy code
const filedata = pulumi.all([inputConnectionString, outputConnectionString]).apply(([ics, ocs]) => {
    fnjson.bind.connectionIn = ics;
    fnjson.bind.connectionOut = ocs;

    return JSON.stringify(fnjson);
});

fs.writeFileSync('./' + fnFolder + '/' + fnName + '/function.json', filedata);
looks like replies do not support code snippets, sorry 😕
w
You’ll need to put the fs.writefilesync inside the apply as well. Anything you want to do with the raw values will need to be inside the apply.
e
ok, cool
thanks for the info!
just wanted to let you know that it worked wonderfully with the things you suggested. Thanks!
👍 1