https://pulumi.com logo
Title
f

flat-queen-33017

05/11/2021, 8:24 PM
hey all, I want to split up my index.ts main file into resource group files (e.g. database.ts and beanstalk.ts) And have the different files connect to each other using es6 imports When I tried this earlier it fails and only picks up index.ts for changes : / Is there a way I can make pulumi pick up changes for a folder? or even a collection of files?
s

swift-telephone-15894

05/12/2021, 3:04 AM
You need to import the other files into your index.ts
and then t should just work
For example my index.ts looks like this
import { staticBucketName, sitemapBucketName } from "./backend/app/buckets";
import { ipv4, ipv6 } from "./frontend/lb";

export const app = { staticBucketName, sitemapBucketName };

export const lb = { ipv4, ipv6 };
the import from "./frontend/lb" loads the lb.ts file which in turn loads a bunch of other files and their associated resources until it has every resource in the plan.
f

flat-queen-33017

05/12/2021, 8:50 AM
ahhh, awesome thanks so much John!
c

cuddly-father-4905

05/12/2021, 9:42 AM
@swift-telephone-15894 @flat-queen-33017 if you want to avoid importing and then exporting, if you set
importsNotUsedAsValues
to
preserve
in
tsconfig.json
then you can just re-export modules in your index file, like:
export * from './buckets';
🙌 1
f

flat-queen-33017

05/12/2021, 7:28 PM
that’s really handy thanks @cuddly-father-4905!
👍 1