Is it necessary to have ${WORKSPACE} directory in serverless package for Lambda?

I have started using Serverless framework with AWS. My source is in Typescript which would be built to JavaScript before deploying. This gets uploaded to S3 and then lambda function is created. I noticed that my lambda functions are over 70MB although I only have a few lines of code with operations that use just the aws-sdk, like querying DynamoDB or SecretsManager.

To investigate this, I downloaded the zipped file which gets uploaded to S3 by serverless framework and unzipped for its content. It has a folder named ${WORKSPACE} which accounts for the 70% of the package memory and it does not seem to have any relevant content for the lambda function.

My package.json looks like this

{
"name": "my-api",
"version": "0.0.1",
"description": "API to retrieve secrets from Secrets Manager",    
"license": "UNLICENSED",
"engines": {
    "node": ">= 14.0.0"
},
"scripts": {
    "build": "tsc -p .",
    "deploy": "sls deploy"
},
"dependencies": {
    "@aws-sdk/client-secrets-manager": "^3.33.0"
},
"devDependencies": {
    "serverless": "^2.59.0",
    "typescript": "^4.4.3"
}
    }

and the relevant part of the serverless.yml looks like this

service: sls-my-api

useDotenv: true

variablesResolutionMode: 20210326

frameworkVersion: '2'

package:
 patterns:
  # Includes
  - 'dist/**.js'
  # Excludes
  - '!./**.md'
  - '!./**.env*'
  - '!.github/**'
  - '!.npm/**'
  - '!coverage/**'
  - '!docker/**'
  - '!docs/**'
  - '!dist/tsconfig.build.tsbuildinfo'
  - '!dist/**.d.ts'
  - '!src/**'
  - '!test/**'
  - '!.eslintrc.js'
  - '!.npmrc'
  - '!.prettier*'
  - '!./tsconfig*.json'
  - '!Jenkinsfile'
  - '!jest.json'
  - '!nest-cli.json'
  - '!run-sonar.sh'
  - '!sonar-project.properties'
  - '!tslint.json'
  - '!.gitattributes'
  - '!.npmignore'
  - '!.s2iignore'
  - '!database/**'

In the Jenkins stages, the following are run

npm run build 
npm run deploy 

Also because of the size limitation, inline editing is not available on the lambda console which usually is a very useful action for me, especially when testing and debugging quickly without having to wait for a redeployment.

Does the directory ${WORKSPACE} have any significance for this deployment? If not, how do I exclude it from the deployment package and make my lambda lean?



from Recent Questions - Stack Overflow https://ift.tt/3kM8vzn
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation