Is there a way to imperatively generating an outpu...
# typescript
f
Is there a way to imperatively generating an output in typescript instead of exporting the value? Like pulumi.export in other languages. I'm trying to avoid having circular dependencies in a complex file structure.
s
Can you explain a little more about your use case?
f
In python or go you can do
pulumi.export("outputname", value)
in order to export the value. In javascript/typescript, you need to do a variable export like
export const outputname = value
. The problem is that when you import this variable somewhere else, you are also running the rest of the code in the same file, not only importing the variable value. In the same file other infra oprations may be executed, which can cause trouble. If instead there could be a way to do like python and export the value by explictly running the command I would avoid doing exports for things that should be exported as stack outputs. Today I need to export the value and export again in the
index.ts
in order to have it as an output, like
export {outputname} from "./resources/someResource"
.
Hey @stocky-restaurant-98004. Does pulumi have something like this for typescript?
s
What goal are you trying to accomplish? Like, what's your use case? What infra are you trying to build?
f
I'm doing microstacks where one stack in one repository (typescript) defines a common infra and other repo (python) consumes some outputs of the common infra in order to generate more resources.
So in the common infra I need to export all the names at the root index file. Would be easier to export directly as a stack output in the corresponding file instead of moving the export to the main index.ts
s
What resources are in the common infra?
f
azure ad app registration, storage account, container app environment, key vault, among other resources
s
So your issue is that you want to create a stack export without executing the rest of the changes in the file?
f
I want to create a stack export without having to do a module export