# Serverless deploys full source code of the service for each lambda function

**URL:** <https://forum.serverless.com/t/serverless-deploys-full-source-code-of-the-service-for-each-lambda-function/11823>\
**Category:** Serverless Framework\
**Created:** [June 22, 2020, 1:08pm UTC](https://forum.serverless.com/t/serverless-deploys-full-source-code-of-the-service-for-each-lambda-function/11823 "2020-06-22T13:08:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![parthpatwala](https://avatars.discourse-cdn.com/v4/letter/p/9dc877/32.png) [@parthpatwala](https://forum.serverless.com/u/parthpatwala)\
**Post date:** [June 22, 2020, 1:08pm UTC](https://forum.serverless.com/t/serverless-deploys-full-source-code-of-the-service-for-each-lambda-function/11823/1 "2020-06-22T13:08:24Z")

</div>

Hi,  
I’m new to the serverless framework and I started learning the framework from the documentation. After setting up a serverless.yml file with three functions and 3 separate handlers for each of those functions, I deployed it in the dev stage.  
Now in the AWS account, each of those 3 Lambda functions contains a full source code of the service. Let’s say one function is to return simply hello response and other function is getting data from the DB then why would I need two other files not related to current function in my lambda function source directory.  
Can someone explain this if I am missing anything?  
Thanks.

---

<div class="post-metadata">

**Author:** ![garethmcc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/garethmcc/32/2276_2.png) [@garethmcc](https://forum.serverless.com/u/garethmcc)\
**Post date:** [June 22, 2020, 4:48pm UTC](https://forum.serverless.com/t/serverless-deploys-full-source-code-of-the-service-for-each-lambda-function/11823/2 "2020-06-22T16:48:39Z")

</div>

Keeping things as simple as possible makes it less likely for there to be an issue. Just zipping everything up and sending it all in one shot is far simpler than trying to determine which function contains which file and potentially get it wrong. Besides, except for taking up a little extra disk space, the additional files do no harm; they do not slow down the execution of your Lambda function.

If you really want to make each function as minimal as possible, you can of course use a plugin to bundle things more efficiently but they add complexity and can cause deployment issues.

---

<div class="post-metadata">

**Author:** ![bearclawstu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bearclawstu/32/4301_2.png) [@bearclawstu](https://forum.serverless.com/u/bearclawstu)\
**Post date:** [June 25, 2020, 7:50am UTC](https://forum.serverless.com/t/serverless-deploys-full-source-code-of-the-service-for-each-lambda-function/11823/3 "2020-06-25T07:50:28Z")

</div>

Hi, I managed to only deploy what I need to the lambda by doing the following.  
Add this above your provider section in the yml file

```auto
package:
 individually: true

```

Then in your function definition you can decide what to include/exlude using this. It applies the exclude first and then the include so effectively you exclude everything and then include only the things you want

```auto
functions:
  myFunction:
    handler: functions/myfunction.hello
    package:
      include:
        - functions/myfunction.js
      exclude:
        - functions/**

```

---

<div class="post-metadata">

**Author:** ![parthpatwala](https://avatars.discourse-cdn.com/v4/letter/p/9dc877/32.png) [@parthpatwala](https://forum.serverless.com/u/parthpatwala)\
**Post date:** [June 25, 2020, 5:44pm UTC](https://forum.serverless.com/t/serverless-deploys-full-source-code-of-the-service-for-each-lambda-function/11823/4 "2020-06-25T17:44:48Z")

</div>

Thanks. I’ll try this out. I also changed my code to typescript so now it’s not even showing me the source code on the lambda function 😀  
I think your solution can optimize the code and reduce the function size.
