-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description:
This appears to be closely related to #1072, however, this issue has been closed citing "de-duplicated builds, which will build same CodeUri for multiple functions".
The issue I'm encountering specifically focuses on de-duplicating dependency packages.
sam build is creating the dependency folders multiple times, even though all the lambdas in my template use the same manifest file (in this case a package.json) and therefore should be able to share the packaged dependency.
For a template with 10+ functions and large dependency package sizes this can use up a substantial amount of disk space which can be a problem for CI runners.
As far as I can see there isn't an option for sharing dependencies within sam build
Steps to reproduce:
Lambda function core details:
Lambda1Function:
Type: AWS::Serverless::Function
Runtime: nodejs18.x
Metadata:
BuildMethod: esbuild
Project structure summary:
project
+-- lambda_1
| +-- lambda_handler.ts
+-- lambda_2
| +-- lambda_handler.ts
+-- package.json
+-- template.yml
Command: sam build --cached
Observed result:
.aws-sam
+-- build
+-- deps
| +-- 0f280905-35ff-4b37-98c2-233b766710d2
| | +-- node_modules
| +-- 40c1b906-e0b8-4762-83a1-03a9c32a15a0
| | +-- node_modules
| +-- d28e775d-8805-4847-913c-47b7cefb2648
| | +-- node_modules
+-- build.toml
Expected result:
In this example I would expect only one set of dependencies within .aws-sam/deps/ because all the functions share the same manifest file.
Additional environment details
SAM CLI, version 1.108.0
Typescript project with esbuild