Hello, I have built a lamba function. It works locally. It has to import a json. When I deploy it with the same code to bitbucket, and build the site, when I call the function and go to the functions tab on netlify. it says file not found.
Error: ENOENT: no such file or directory, open ‘/var/task/lambda/connection.json’
I’m pretty positive the path is correct. How do I access a JSON from a lambda function? It doesn’t seem that the JSON actually gets included in the build and deploy, so it sits in bitbucket but never gets built. How do I include this? I dont need a database for something so simple right?
someone please help me, I’ve been stuck on this for days, almost a week. I just want to use a JSON in my lambda function. Do I need to now set up a data base and call that? Or can I just store it in a file next to my lambda function?
Thanks! I downloaded the site, however, this is only the front-end. None of the lambda functions get downloaded. Do you know how I would do this? Im still stuck on this
Hi, @chrisleeharris. You are correct that the functions are not available in the deployment zip file.
It sounds like the require JSON file isn’t being bundled into the function archive so isn’t available post deployment.
Here is an example community topic where someone else is asking something similar:
One tool to prepare/bundle functions for deployment is the “zip-it-and-ship-it” tool:
Also, @marcus here at Netlify created the following repo as a demo of how this (bundling a JSON file to be read in by the function) can be done:
I’m hoping these examples provide additional insight into the how files, JSON or other types, are bundled with function code to be accessible by the function after deployment.
If there are other questions or if there is more we can do to assist, please let us know.
@luke Thanks! ive read through it all, but what are the actual commands I would use to zip this? Some places I see using netlify deploy, but does then I read you need to zip it and ship it before. What are the actual real steps for this? I dont really see anything on that
What is going on? Why is it so difficult for me just to require files in my lambda functions? Is this how netlify lambda functions will be? I have been at this for days and if I didn’t use this Lambda function approach, I could have been finished days ago. Am I doing something wrong??
I got my first JSON to load, but now I am trying to get an id file to load next to it, ugh, the file is literally sitting next to it I have functions for this, but NOOOOOOO, lambda functions dont allow you to import files without a bunch of mumbo jumbo. How do you use zip-it-and-ship it I havent found a single doc where it shows how to actually implement it???
Hi there. @marcus I am trying your example GitHub - mraerino/netlify-functions-readfile but i just got this error “error decoding lambda response: error decoding lambda response: json: cannot unmarshal object into Go struct field .body of type string” when running the function.
Thanks for your help.