Serverless deploy how to reference code from different directory

Hi

I am trying to build different api packages using the same code base. my code structure is as follows

  • src
    • function1
      • function 1 code files
    • function2
      • function 2 code files
    • function3
      • function 3 code files
  • node_modules
  • deployment
    - yml
    - function1.yml
    - function2.yml
    - function3.yml
    - packages
    - package1 // for only function 1 and 2
    - serverless.yml
    - package2 // for only function 2 and 3
    - serverless.yml
    - fullpackage // for all function
    - serverless.yml

function yml contains only single lambda related configuration and serverless.yml combines the function configs using file includes

the problem I am facing is when I run serverless deply from package directories it not picking the source directory. it only picks the code directory only when serverless.yml is at root and serverless deploy is run from project root.

how can i pass code path dynamically on deployment

Thanks

Packaging code dynamically on deployment goes against deployment best practices - your deploys should be explicit and easily repeatable, so that you can do things like reliably roll-back in the event of a deployment issue or bug. You want to be sure that the code/package you tested in your development environment is exactly the same as the code you deploy to production.

The only way I can think to make your setup work would be to “vendor” your code internally (i.e. create modules out of them) and then use something like npm link to share it between your functions.