Some excerpts of how we build and deploy two lambdas. In this case these will end up as lambda@edge for a cloudfront distribution for handling viewer-requests and origin-requests.
The main point is how the origin-request lambda in the deploy-lambda
section includes the node_modules directory into the lambda zip image. Lambda@edge can't have the image be bigger than 50MB. So we do
yarn install --production
To install only the production parts of the dependencies, Then use modclean
to reduce the size of node_modules further.
Had problems doing the direct file upload for aws lambda update-function-code
so used the s3 upload option for the origin-request lambda.