question

Bill M. avatar image
Bill M. asked ·

nodejs lambda layers not finding module

I have a hello Lambda using oneagent that works if I include the node_module in the zip I upload for the Lambda. I followed the instructions from the enable serverless dialog.

I'm trying to move the node_modules to a Lambda Layer with the nodejs/node_modules/@dynatrace/oneagent pathing. I know the layer can be found as I can load mysql. It seems like something is wrong with my handler reference but who knows. Has anyone tried this?

Here's the reference that worked before. node_modules/@dynatrace/oneagent.main$handler


agentoneagentnodejs
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Bill M. avatar image
Bill M. answered ·

The main use case is we have created a lambda layer of common packages at specific versions that we want each Lambda to use. It makes debugging issues much easier and faster if you know what's going on and don't have to scan the packages for differences. The common packages layer is versioned and not modified based on the whim of every dev. We currently have multiple teams that will use our layers based on their need.

Currently, every dev will have to add the package to their lambda. They may or may not optimize for deployment or may target the wrong node version. We expect several hundred new lambdas in the next year. This also means upgrades will be painful.

Also - the general benefits of using layers. Smaller deployment package, single code base, etc.

So bottom line is code management and scaling.

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

Michal N. avatar image
Michal N. answered ·

Hi Bill,
I'm afraid that just moving the node_modules into a Lambda Layer would not work.
What would be the use case for such move?

Best
Michal Nalezinski
Technical Product Manager

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.