Skip to content

Serverless python custom packaging with nested folders #435

Open
@gzp-gnr

Description

@gzp-gnr

Hi, I have this following project structure

src/
    requirements.txt
    function_a.py
    function_b.py
    common/
        common_1.py
        common_2.py

With this function configuration the zip artifacts contains the common and function_* lambda source files plus dependencies, which is what I want.

Serverless configuration - 1

 functionA:
    module: src
    handler: function_a.handler
    package:
      include:
        - src/common/**
        - src/function_a.py

  functionB:
    module: src
    handler: function_b.handler
    package:
      include:
        - src/common/**
        - src/function_b.py

Now I would like to move the function_b to a nested src folder src/function_b and have its own requirements.txt file

src/
    requirements.txt
    function_a.py
    function_b/
        function_b.py
        requirements.txt
    common/
        common_1.py
        common_2.py

but when I try to pack it using this serverless configuration the function_b zip file doesn't contain the /common/** sources but only the function_b and its dependencies.

Serverless configuration - 2

  functionB:
    module: src/function_b
    handler: function_b.handler
    package:
      include:
        - src/common/**
        - src/function_b/function_b.py

The other relevant part of the serverless.yml file is this

pythonRequirements:
    slim: true
    useStaticCache: true
    useDownloadCache: true
    cacheLocation: './._cache'
    staticCacheMaxVersions: 10
    dockerizePip: non-linux

package:
  individually: true
  exclude:
    - ./**

Is there something I am doing wrong or is this some plugin/serverless limitation/bug ?

Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions