AWS Lambda internal node module - node.js

As far as I know, there are node modules that are automatically installed by AWS Lambda.
Is it excluded if you know that the module included a request module?
If anyone knows about this part, I would appreciate it if you could let me know.
Thank you.

request module is not installed by default, only NodeJS standard libraries and aws-sdk are installed by default and the rest of modules will originate from either your lambda layers or the lambda function's node_modules. You can find more details from here.

Related

Express JS in Altassian Forge causing "process.cwd is not a function" error

I am new to development on Jira Cloud and am currently exploring creating apps using the Atlassian Forge. I was trying to use Express JS in the code as a middleware. Turns out that during deployment, it keeps giving this error "process.cwd is not a function."
The error received while deploying the app.
I tried installing process module (via npm i process; which was successfully done) and updating the webpack version but none of it worked.
Can someone please tell what could be causing this error?
If possible please suggest the alternative for using Express JS in Altassian Forge?
Thanks in advance.
Apoorva
From the documentation:
When a Forge app is invoked, the JavaScript code is executed within the app sandbox. This environment differs from a traditional Node.js environment you might already be familiar with.
You'll need to write your functions in a subset of Node.js. Some globals are not exposed, for example:
process (except for process.env)
queueMicrotask
which means that some NPM packages that depend on these may not function correctly.
If Express JS depends on process.cwd(), that would explain the error. You may be able to work around this if it depends on it in theory but not in practice:
If process.cwd() is only used in test cases or example code, you can delete it or make sure it's not bundled.
If it is used, but using a dummy string like "/" would work, you could stub out the call using DefinePlugin or similar.

Debugging AWS Lambda node.js ES6

I am trying to debug an AWS Lambda using lambda-local but the problem is that it doesn't recognize imports and exports in node.js.
Is there a workaround other than back-refactoring my entire API to requires?
Imports and exports are not yet supported in Node.
You have two options:
1. Change your imports to use require. Or,
2. Use babel to transpile your code before deploying to Lambda.
If you use serverless-framework, the serverless-webpack plugin will be of big help to you.

Why serverless lambda deploy will error with: No module named '_sqlite3' ?

There are other similar question like mine, but I think no one looks complete or fits/answer my case.
I'm deploying a Python 3.6 application on AWS lambda via serverless framework.
With this application I'm using diskcache to perform some small file caching (not using at all sqlite actually)
I'm using "serverless-python-requirements" plugin in order to have all my dependencies (defined in requirements.txt file) packed up and uploaded (diskcache in this case)
When application is live on AWS and I request it, I'll get back a 500 error. And in my logs I can read:
Unable to import module 'handler': No module named '_sqlite3'
Then from answer below I get that sqlite module should not be needed to be installed.
Python: sqlite no matching distribution found for sqlite
So no need (and it wont work) to add sqlite as a requirement...
Then I wonder why AWS lambda is unable to find sqlite once deployed.
Any hint pls?
Thanks

importing python modules in aws lambda

I have about 40-42 python modules to use in my lambda functions, does it mean i have to make a zip of all with my main handler.py and upload. I know about boto-3 but could not get through it as the documentation is not specific. Could someone help to find the easiest way to get around this.
Unfortunately (with exception of the aws-sdk) it's up to you to package and include all your modules when deploying to Lambda.
Luckily this is such a common task that there are a few good frameworks out there to help you automate this process, such as:
Serverless Framework (with Python Requirements): https://github.com/UnitedIncome/serverless-python-requirements
Chalice: https://github.com/aws/chalice
n.b. this isn't unique to Python- node developers have to include their node_modules, and Golang devs have to compile to a static executable.

CRUD operations to couchbase from AWS Lambda using couchbase sdk for node.js

I need to run CRUD operations on my bucket (database) in couchbase which is deployed ec2 instance. And the code which I have is running on aws lambda. However, when I try to test this code on lambda by passing details in the body I get the error as : "errorMessage": "/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /var/task/node_modules/couchbase/build/Release/couchbase_impl.node)". This error is because in my function I require an npm module called "couchbase" which is used for executing CRUD operations on my couchbase bucket.
So can you guys help me as to what might be the problem here? Is the file missing on nodejs environment running on lambda or do I need to implement in a different way so as to get it working?
Thanks in advance.
I was able to solve this issue by locally compiling node_modules with the same nodejs version (v0.10.36) which lambda uses and uploading the zip file to lambda.

Resources