https://pulumi.com logo
Title
f

few-postman-20852

03/24/2023, 2:59 PM
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

stocky-restaurant-98004

03/24/2023, 4:30 PM
Can you explain a little more about your use case?
f

few-postman-20852

03/25/2023, 9:00 AM
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

stocky-restaurant-98004

03/28/2023, 1:26 PM
What goal are you trying to accomplish? Like, what's your use case? What infra are you trying to build?
f

few-postman-20852

04/04/2023, 11:58 AM
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

stocky-restaurant-98004

04/04/2023, 3:00 PM
What resources are in the common infra?
f

few-postman-20852

04/20/2023, 6:27 AM
azure ad app registration, storage account, container app environment, key vault, among other resources
s

stocky-restaurant-98004

04/20/2023, 7:35 PM
So your issue is that you want to create a stack export without executing the rest of the changes in the file?