Is there a way to output besides `export`? I've go...
# typescript
p
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
export const
will do the same thing
p
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
yep that should work, you can export any constant, basically
p
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
For better or worse, Pulumi will accept vars = undefined and then happily not log any undefined values to the console.
p
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