https://pulumi.com logo
#general
Title
# general
b

brave-afternoon-91593

11/03/2021, 3:46 AM
We’re beginning to adopt Pulumi more broadly within our organization. As such, we’re needing simple abstractions that can be re-used across projects, namely helper functions to create opinionated AWS and Kubernetes providers (we just fetch kubeconfigs from S3 and create k8s providers accordingly). I’m just working in a single repository that contains multiple subdirectories, each containing their own Pulumi project. I’d like to create
/lib/**/*.ts
, then install it by adding something like
"lib": "file:../lib"
to my
package.json
in each of the other directories. However, I don’t want this lib to define provider versions, rather I’d like the lib’s
package.json
to simply reference
peerDependencies
of the referenced Pulumi providers. However, when I do this, pulumi fails to preview thanks to
error TS2307: Cannot find module '@pulumi/aws|kubernetes'.
This is probably just a Typescript question, but surely there’s a way to tell typescript that the types referenced in the libs should refer to the types defined in the project package.json.
b

billowy-army-68599

11/03/2021, 3:48 AM
are you creating ComponentResources? life gets a whole lot easier if you do that, you can just do
npm install ../common/fargate_webapp/
b

brave-afternoon-91593

11/03/2021, 3:48 AM
Well, I think I’d have the same issue. The “common” lib would have to have the providers installed by version, right?
Ideally, they’d only be referenced as PeerDeps.
Sure, I could wrap the creation of my providers in a ComponentResource and return them as outputs. Not a bad idea. 😛 Was just exporting functions that return the providers.
b

billowy-army-68599

11/03/2021, 3:50 AM
with a ComponentResource you can create your own package with provider versions for each Component
or are you trying to keep the same version across all?
b

brave-afternoon-91593

11/03/2021, 3:50 AM
Yea, that’s the idea. The lib doesn’t specify a version; just implies the consuming project has them installed.
b

billowy-army-68599

11/03/2021, 3:51 AM
hrm not super familiar with that, will do some reading and see if I can come up with an answer
b

brave-afternoon-91593

11/03/2021, 3:51 AM
Ultimately, it’s just the version of the SDK, not the actual provider runtime version, yeah?
That said, I don’t want to run into this version conflict scenario, cuz our libs and consuming projects will get stale. 😛
b

billowy-army-68599

11/03/2021, 4:14 AM
the provider runtime and sdk should be the same
4 Views