sparse-intern-71089
02/19/2020, 7:38 PMgorgeous-egg-16927
02/19/2020, 8:31 PMpulumi.all
to resolve all the outputs.
(not tested, but should be close)
pulumi.all([vpcName, vpc.id]).apply(([name, id]) => console.log(`Applying ${name} = ${id}`))
calm-quill-21760
02/19/2020, 8:43 PMcalm-quill-21760
02/19/2020, 8:52 PMlet vpcNameToId: { [index: string]: any } = {};
for (let vpc of vpcList) {
// create a lookup table
const vpcName = vpc.tags.apply(v => v?.Name ?? null);
const vpcId = vpc.id;
pulumi.all([vpcName, vpcId]).apply(([name, id]) => {
vpcNameToId[name] = id;
});
}
console.log("" + Object.keys(vpcNameToId).length);
Here the console output is zero items.gorgeous-egg-16927
02/19/2020, 9:02 PMvpmNameToId
into an Output and passing it into the pulumi.all
. At that point, you can resolve that output as usual like
vpcNameToId.apply(map => console.log(Object.keys(map).length))
calm-quill-21760
02/19/2020, 10:03 PMcalm-quill-21760
02/21/2020, 9:22 PMgorgeous-egg-16927
02/21/2020, 9:56 PMwhite-balloon-205
pulumi.output(x)
is effectively Promise.resolve(x)
but for outputs.white-balloon-205
As I puzzle through this, I end up with "apply" inside "apply" statements just to ensure everything is resolved.This should not be the case in general - though depends a bit on specific code you are trying to write.
white-balloon-205
calm-quill-21760
02/21/2020, 9:58 PMcalm-quill-21760
02/21/2020, 9:59 PMwhite-balloon-205
apply
. TypeScript doesn't provide any way to offer generalized await
-style syntax (in a pleasent way) over non-promises.calm-quill-21760
02/21/2020, 10:02 PMcalm-quill-21760
02/21/2020, 10:03 PMwhite-balloon-205
pulumi.all(var).apply()
is reasonably commonly needed.calm-quill-21760
02/21/2020, 11:07 PMcalm-quill-21760
02/22/2020, 12:01 AM