# Serverless deploy how to reference code from different directory

**URL:** <https://forum.serverless.com/t/serverless-deploy-how-to-reference-code-from-different-directory/2216>\
**Category:** Serverless Architectures\
**Tags:** aws\
**Created:** [July 5, 2017, 10:41am UTC](https://forum.serverless.com/t/serverless-deploy-how-to-reference-code-from-different-directory/2216 "2017-07-05T10:41:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkkumargoyal](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/dkkumargoyal/32/777_2.png) [@dkkumargoyal](https://forum.serverless.com/u/dkkumargoyal)\
**Post date:** [July 5, 2017, 10:41am UTC](https://forum.serverless.com/t/serverless-deploy-how-to-reference-code-from-different-directory/2216/1 "2017-07-05T10:41:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rowanu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rowanu/32/75_2.png) [@rowanu](https://forum.serverless.com/u/rowanu)\
**Post date:** [July 6, 2017, 2:23am UTC](https://forum.serverless.com/t/serverless-deploy-how-to-reference-code-from-different-directory/2216/2 "2017-07-06T02:23:09Z")

</div>

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`](https://docs.npmjs.com/cli/link) to share it between your functions.
