https://pulumi.com logo
#typescript
Title
# typescript
p

purple-application-23904

11/17/2021, 9:15 PM
Is there a way to output besides
export
? I've got helper functions to help wrap some common group of resources, but by only using
export
I can't programmatically export parts of those resources. The other languages seem to have this (eg. python has
pulumi.export(name, value)
)
b

billowy-army-68599

11/17/2021, 9:32 PM
export const
will do the same thing
p

purple-application-23904

11/17/2021, 9:36 PM
If I had a
Map<string, pulumi.Output<any>>
could I export that?
I'd prefer it to be top-level, but nesting it with some generic name would suffice I suppose (eg
export const vars = output
)
b

billowy-army-68599

11/17/2021, 9:38 PM
yep that should work, you can export any constant, basically
p

purple-application-23904

11/18/2021, 6:08 PM
Hm, this didn't seem to work, it's not displaying the map's variables (it didn't display the exported
vars
at all)
o

orange-kite-80991

11/21/2021, 7:37 AM
For better or worse, Pulumi will accept vars = undefined and then happily not log any undefined values to the console.
p

purple-application-23904

11/22/2021, 5:25 PM
The map isn't undefined, if I
console.log
the value I can see the values, but at the end there's no output.
Not that this is that complicated, but just to be explicit, I'm doing something like this:
Copy code
const cloudLib = new ...

cloudLib.createWebsocketGateway(...)

export const vars = cloudLib.outputs
console.log("vars", vars)
where outputs is
Copy code
outputs: Map<string, pulumi.Output<any>> = new Map();
FWIW, to circle back on this - the following did work:
Copy code
export const vars = Array.from(cloudLib.outputs).reduce((obj, [key, value]) => (
  Object.assign(obj, { [key]: value })
), {});
So it looks like it just doesn't like
Map
but
object
is okay