serverless-plugin-warmup icon indicating copy to clipboard operation
serverless-plugin-warmup copied to clipboard

Packaging should not include service level patterns

Open estahn opened this issue 3 years ago • 1 comments

We have the following config which adds all python code also into the warmUpPluginOfficeHoursWarmer.zip. I tried various variations to exclude the files and the only thing that worked is setting package.individually to true or moving the package block into the function. Moving the package block into the function does not apply the patterns though and we will end up with a large zip file.

Imo package.patterns should not be joined to package the warmer function.

functions:
  app:
    handler: wsgi_handler.handler
    timeout: 30
    layers:
      - Ref: PythonRequirementsLambdaLayer
    warmup:
      officeHoursWarmer:
        enabled: prod

package:
  individually: false
  patterns:
    - "!**"
    - "serverless_sdk*/**"
    - "app/**"
    - "module1/**"
    - "module2/**"
    - "module3/**"
    - "*.py"

What worked:

functions:
  app:
    handler: wsgi_handler.handler
    timeout: 30
    layers:
      - Ref: PythonRequirementsLambdaLayer
    package:
      patterns:
        - "!**"
        - "serverless_sdk*/**"
        - "app/**"
        - "module1/**"
        - "module2/**"
        - "module3/**"
        - "*.py"
    warmup:
      officeHoursWarmer:
        enabled: prod

package:
  individually: true

estahn avatar Sep 20 '22 11:09 estahn

Hi @estahn ,

Cascading the package settings (i.e. joining the patterns set at package level to the ones set at the function) is the behaviour of the Serverless framework.

You can also exclude the packages from the warmer config:

package:
  individually: false
  patterns:
    - "!**"
    - "serverless_sdk*/**"
    - "app/**"
    - "module1/**"
    - "module2/**"
    - "module3/**"
    - "*.py"

custom:
  warmup:
    officeHoursWarmer:
      package:
        patterns:
          - "!serverless_sdk*/**"
          - "!app/**"
          - "!module1/**"
          - "!module2/**"
          - "!module3/**"
          - "!*.py"

functions:
  app:
    handler: wsgi_handler.handler
    timeout: 30
    layers:
      - Ref: PythonRequirementsLambdaLayer
    warmup:
      officeHoursWarmer:
        enabled: prod

juanjoDiaz avatar Sep 27 '22 19:09 juanjoDiaz

Closing since a solution has been provided and there has been no more responses

juanjoDiaz avatar Oct 30 '22 20:10 juanjoDiaz