5

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?

1 Answer 1

6

After some time researching i found solution. So here it is:

service: MyService

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

provider:
  name: aws
  runtime: nodejs6.10
  stage: dev
  memorySize: 512
  timeout: 10

functions:
    Function1:
       handler: functions_folder/Function1.handler
       package:
         include:
           - functions_folder/Function1.js

    Function2:
       handler: functions_folder/Function2.handler
       package:
         include:
           - functions_folder/Function2.js

     Function2:
       handler: functions_folder/Function3.handler
       package:
         include:
           - functions_folder/Function3.js

So as you can see in package section i have added include/exclude part, at first i'm excluding all files then i'm include 2 needed folders "common" and "node_modules". After this for each function i also use include command for to add only needed file.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, after searching the docs and trying similar but not quite the same solutions from various other places this got be across the line 👍

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.