Eric - interesting post… wondered if you had any insight into what I’m stuck on.
I’m trying to get an AWS lambda function to use airtable.js to call the Airtable API. I’m getting an error as the lambda loads up. I’ve created a lamdba layer containing the airtable.js package (npm install -s airtable) and that gets found OK but then I get this:
Error: Cannot find module '/var/task/node_modules/abort-controller/dist/abort-controller'. Please verify that the package.json has a valid \"main\" entry
I’ve also tried zipping the node package up with the function itself into a deployment package instead of using a layer, but with the exact same results. Tried both node 12.x and 14.x.
And I’ve tested locally - npm install -s airtable and then node test.js - and it works perfectly. (node 14.15.0)
What’s going on with airtable.js on aws lambda? Any ideas?
Spot on. I don’t understand why, because what I was doing is exactly what I’m doing with about 25 other lambda functions and layers, which are all working perfectly. I can’t see anything different here…
My setup is that I’m provisioning all my AWS resources with Terraform, and my tf config zips up the layers and functions as part of the deployment. As I say, that works flawlessly elsewhere … but not here. Now I have to go and work out why - or change my toolchain to upload a zip separately before the terraform config picks it up.
To answer your curiosity - we have a public-facing form which is too complex for the standard Airtable form view to easily handle and don’t want to be dependent on other paid services. Lambda is the perfect low-cost route for what we need, with nearly all the subsequent data handling and processing sitting in Airtable.
Thanks very much for taking the trouble to reply, and coming up with the solution.