Hello, when I run my API deploy command, I receive the error:
CREATE_FAILED: ApiLambdaFunction (AWS::Lambda::Function) Resource handler returned message: “Unzipped size must be smaller than 262144000 bytes.”
But the zip file is 174MB. If I set the node_modules to be deleted in the serverless.yml, then I get the error “Cannot find module ‘serverless-http’” and the same for any other dependency of my API. Does anyone know how I can solve this?
serverless.yml:
frameworkVersion: '3'
useDotenv: true
provider:
name: aws
runtime: nodejs18.x
stage: ${opt:stage}
apiGateway:
binaryMediaTypes:
- '*/*'
functions:
api:
handler: src/shared/infra/http/serverlessHandler.handler
events:
- httpApi: '*'
- http:
path: /api-docs/{proxy+}
method: get
cors:
origin: '*'
headers:
- Content-Type
- Authorization
- x-amzn-trace-id
plugins:
- serverless-plugin-typescript
- serverless-offline
- serverless-dotenv-plugin
- serverless-plugin-include-dependencies
package:
excludeDevDependencies: false
individually: true
patterns:
- '!node_modules/.prisma/client/libquery_engine-*'
- 'node_modules/.prisma/client/libquery_engine-rhel-*'
- '!node_modules/prisma/libquery_engine-*'
- '!node_modules/@prisma/engines/**'```
script deploy:
“predeploy:prod”: “dotenv -e .env.production – npx prisma generate”,
“deploy:prod”: “npm run predeploy:prod && sls deploy --verbose --stage production”,
My API is built with Express, TypeScript, using Prisma, and MongoDB.