is there a way to have stack outputs in a differet file rather the index.ts?
s
strong-vr-23014
10/15/2024, 5:41 PM
Yeah there is, hopefully others will comment if this is a better way of doing it but heres what I have seen/do
As a very basic example:
in `index.ts`:
Copy code
export * from './resources';
And then in
resources.ts
just create your outputs as you would normally along with your other resources (you have to export them in this file as well so they are available for export in
index.ts
).
b
bland-pharmacist-96854
10/15/2024, 5:43 PM
so this way I could use that in combination with import('./resources')
bland-pharmacist-96854
10/15/2024, 5:53 PM
and what about if I want to export something from inside a function?
s
strong-vr-23014
10/15/2024, 5:58 PM
yeah you can import the function into index and call it to create your resources, and I'd probably just return whatever you want from the function and then create an output from it.
I'm pretty new to
pulumi
and I think things that are exported "all the way" become outputs automatically? Just have a play around with it
b
bland-pharmacist-96854
10/15/2024, 5:58 PM
I mean, in general I'm struggling a little bit about how to organize my pulumi code by ts modules, but probably is my lack of TS knowledge.
In general I do things like:
index.ts
import {myresurces} from ./mymodule
myresources() {}
mymodule.ts
myresources() {resources}
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.