Best practices for api and lambda layers #261
Replies: 1 comment 1 reply
-
I think it makes sense to have the typeorm as its own typescript project if it's referenced by multiple other parts of your application. The .projenrc.ts const common = new TypeScriptProject({
name: '@my-project/typeorm-common',
...
});
common.postCompileTask.exec('cp -r src/typeorm lib/'); For usage in your lambda - if you are using new NodejsFunction(this, 'ApiLambda', {
...
bundling: {
nodeModules: ['@my-project/typeorm-common'],
},
}); Hope that helps! :) |
Beta Was this translation helpful? Give feedback.
-
I am trying to create a lambda layer that gets consumed by an API operation lambda.
I have an apiInfra stack which is responsible for the infrastructure supporting the api (like the layer) and instantiating the api.
The layer has its own dependencies.
I have tried having the layer as a projen typescript project. However, the apiInfra stack needs to take a dependency on the built layer. This fails as projen enforces a rootDir prohibiting access to files outside of the stack.
The scenario here is to use typeorm across the entire application. This means the models etc are "common" and need to be referenced from multiple places such as the api lambda.
Any suggestions on the right design pattern would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions