All functions included in package but needed only one

aws

#1

Hello everyone. I’m new in serverless and i have one question.
My service structure:

-MyService
    -common
    -node_modules
    -functions_folder
        -Function1.js
        -Function2.js
        -Function3.js

yaml file:

service: MyService

provider:
  name: aws
  runtime: nodejs6.10
  stage: dev

functions:
    Function1:
       handler: functions_folder/Function1.handler
       memorySize: 512
       timeout: 10
   
    Function2:
       handler: functions_folder/Function2.handler
       memorySize: 512
       timeout: 10
    
     Function2:
       handler: functions_folder/Function3.handler
       memorySize: 512
       timeout: 10

When i’m deploying, i have 3 different lambda functions, but each one contain Function1.js, Function2.js, Function3.js inside.

Can somebody explain me please how to exclude from resulted Lambda not needed files?


#2

See docs for package exclude/include properties:


#3

Haven’t tested it, but this should be the yaml snippet for your desired behaviour:

service: MyService

provider:
  name: aws
  runtime: nodejs6.10
  stage: dev

package:
  individually: true
  include:
    - common/**
    - node_modules/**
  exclude:
    - functions_folder/**

functions:
  Function1:
    handler: functions_folder/Function1.handler
    memorySize: 512
    timeout: 10
    package:
      include:
        - functions_folder/Function1.handler

  Function2:
    handler: functions_folder/Function2.handler
    memorySize: 512
    timeout: 10
    package:
      include:
        - functions_folder/Function2.handler

  Function3:
    handler: functions_folder/Function3.handler
    memorySize: 512
    timeout: 10
    package:
      include:
        - functions_folder/Function3.handler