https://pulumi.com logo
#general
Title
# general
e

early-family-43281

04/02/2019, 3:05 PM
any suggestions?
w

white-balloon-205

04/02/2019, 3:08 PM
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

early-family-43281

04/02/2019, 3:10 PM
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

white-balloon-205

04/02/2019, 3:11 PM
Then same as above - but write the values into the object inside the apply instead of using them to construct a new object.
e

early-family-43281

04/02/2019, 3:12 PM
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

white-balloon-205

04/02/2019, 3:35 PM
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

early-family-43281

04/02/2019, 3:36 PM
ok, cool
thanks for the info!
just wanted to let you know that it worked wonderfully with the things you suggested. Thanks!
👍 1