# Using data from Lambda layers / zipping a function

**URL:** <https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866>\
**Category:** Support\
**Tags:** lambda-functions\
**Created:** [May 11, 2019, 7:21am UTC](https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866 "2019-05-11T07:21:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aeaton](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/aeaton/32/633_2.png) [@aeaton](https://answers.netlify.com/u/aeaton)\
**Post date:** [May 11, 2019, 7:21am UTC](https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866/1 "2019-05-11T07:21:50Z")

</div>

I have some functions that I’d like to deploy, but they use data from files in a folder in node\_modules without directly specifying each path using `require`, so those data files don’t get bundled with the function.

It feels like [Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) might be a good place to store this extra data for use in Netlify functions. Is it possible to configure a function so that it has access to one or more layers?

---

<div class="post-metadata">

**Author:** ![futuregerald](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/futuregerald/32/33_2.png) [@futuregerald](https://answers.netlify.com/u/futuregerald)\
**Post date:** [May 13, 2019, 2:38pm UTC](https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866/2 "2019-05-13T14:38:11Z")

</div>

Hi @aeaton,

Thanks for joining the community. I actually never considered that in the past, but at the moment you can’t use layers with Netlify deployed lambda functions. The current best way to get the data you need is to include it as part of the deploy. You can zip your function and it’s `node_modules` and deploy that together and then your function will have access to those node\_modules. However at some point you’ll have to pull in that data, are you accessing them directly via the file system? Is there a reason you aren’t importing them using `require` or something similar? I’d love to understand your use-case more so we can see if there’s a better workflow for you.

---

<div class="post-metadata">

**Author:** ![aeaton](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/aeaton/32/633_2.png) [@aeaton](https://answers.netlify.com/u/aeaton)\
**Post date:** [May 21, 2019, 1:23pm UTC](https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866/3 "2019-05-21T13:23:20Z")

</div>

> [@futuregerald](#):
>
> You can zip your function and it’s `node_modules` and deploy that together and then your function will have access to those node\_modules.

I’m using the Netlify GitHub app to build and deploy the functions - is it possible to tell the builder that it should include the `node_modules` folder (or specific parts of it)?

---

<div class="post-metadata">

**Author:** ![aeaton](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/aeaton/32/633_2.png) [@aeaton](https://answers.netlify.com/u/aeaton)\
**Post date:** [May 21, 2019, 2:11pm UTC](https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866/4 "2019-05-21T14:11:11Z")

</div>

> [@futuregerald](#):
>
> However at some point you’ll have to pull in that data, are you accessing them directly via the file system? Is there a reason you aren’t importing them using `require` or something similar?

The files are accessed via the file system, yes. The path to an initial file is located using `require.resolve(…)`, then from there other files are loaded via a relative path.

---

<div class="post-metadata">

**Author:** ![futuregerald](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/futuregerald/32/33_2.png) [@futuregerald](https://answers.netlify.com/u/futuregerald)\
**Post date:** [May 23, 2019, 5:17pm UTC](https://answers.netlify.com/t/using-data-from-lambda-layers-zipping-a-function/866/5 "2019-05-23T17:17:18Z")

</div>

Hi @aeton you’ll need to zip the function and `node_modules` together and deploy that zipped directory. Then you’ll have access to anything in your module the same way you would any other dependency.
