Hi, I am new to Pulumi and I noticed that contrair...
# typescript
e
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
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
hmmm, well, that is basically what I said.
but thanks
f
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
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