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

eager-pillow-75917

04/13/2020, 12:35 PM
Hi, I am new to Pulumi and I noticed that contrair to Terraform, that the tf files just need to be in the same directory, Pulumi deploys from the
index.ts
. I am separating my infrastructure into separate file for sake of organization and separation. But I noticed that I not only have to import to index.ts, but I have to use it somehow. Even it is a simple export of output in the end for Pulumi to deploy whatever it is on the import. Is there a better way to do this? A best practice maybe that most of you are following?
l

limited-rainbow-51650

04/13/2020, 2:50 PM
We are using real code now, so the rules of the runtime (in this case Typescript) apply here. The entrypoint to your “program” is
index.ts
. You can structure to multiple files, but you have to
import
them in your
index.ts
file.
e

eager-pillow-75917

04/13/2020, 3:32 PM
hmmm, well, that is basically what I said.
but thanks
f

faint-table-42725

04/13/2020, 3:46 PM
To add to what @limited-rainbow-51650 said, you can control the entrypoint for Pulumi just as you would any Node program by configuring the
main
property in your
package.json
— for example, you could have
"main": "infrastructure.ts"
as your entry point instead of the default
index.ts
w

white-balloon-205

04/14/2020, 6:32 PM
But I noticed that I not only have to import to index.ts, but I have to use it somehow
Note that if you use
import "./vpc"
syntax, you do not need to "use" the outputs of the imported module for it to be included. This is a slightly unfortunate TypeScript gotcha even outside of Pulumi. https://github.com/microsoft/TypeScript/issues/9191#issuecomment-226258610