I am currently researching AWS lambda functions and I can't find anywhere if I can use the require statement in them so that I can use other, non-lambda functions. I know about zipping the node modules folder but this doesn't help me here as I don't intend to use a node module, thanks for any answers!
You can use a Lambda function to process requests from an Application Load Balancer. Elastic Load Balancing supports Lambda functions as a target for an Application Load Balancer. Use load balancer rules to route HTTP requests to a function, based on path or header values.
The Lambda runtimes for Python 3.8 and later do not include the 'requests' module. Customers using 'requests' with these runtimes should package the 'requests' module with their function code or as a Lambda layer. Update (November 11, 2021):
You do not want to use Lambda for long-running workloads because it runs instances/functions for up to 15 minutes at a time. It limits concurrent function executions to 1,000. AWS Lambda bills can quickly run through your budget if you are unsure how to optimize AWS costs.
Just to add to Justin's answer, yes you can require other files in lambda with this structure as an example:
| main.js << The handler is here
| func1.js
| func2.js
and in the main file:
// main.js
require('./func1.js');
require('./func2.js');
Yes, you can. You just have to ensure that the node_modules
folder is uploaded as part of your package (you won't be able to use the console editor). You can read more details on the AWS Blog:
Using Packages and Native nodejs Modules in AWS Lambda
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With