hi! Could someone help me figure out how to get re...
# typescript
e
hi! Could someone help me figure out how to get resources registered with pulumi? my project is structured like
Copy code
pulumi
├── Pulumi.dev.yaml
├── Pulumi.yaml
├── README.md
├── gcp
│   ├── README.md
│   ├── index.ts
│   └── k8s.ts
├── index.ts
├── k8s
│   ├── index.ts
│   ├── namespace.ts
│   └── secret.ts
├── package-lock.json
├── package.json
└── tsconfig.json
and in the
pulumi/index.ts
Copy code
import * as gcp from './gcp'

export let devKubeconfig = gcp.devKubeconfig
My problem is that none of resources in the
pulumi/k8s/
dir are getting picked up by pulumi when i run
pulumi up
. If I import the resources and then export one of them in the
pulumi/index.ts
then they show up. Trying to figure out what I am doing wrong
c
we use this NPM Package for Environment configs within Pulumi https://www.npmjs.com/package/config
And the more specific implementation of it is managed by setting a pulumi config variable on the stack which is used by the NPM Config package referenced here: https://github.com/lorenwest/node-config/wiki/Environment-Variables#node_config_env
g
@early-match-56268 you must import your k8s resources from somewhere in your application. They will not automatically be picked up in sub-directories. Also, you must use an exported object otherwise Node will "optimize" it away as unused. This is explained in more detail at https://www.typescriptlang.org/docs/handbook/modules.html#optional-module-loading-and-other-advanced-loading-scenarios.
e
thanks, did not know about the unused optimization. exporting the resources fixes the issue
👍 1
g
It confused me at first too. 🙂