-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow importing handler from layers #20
Comments
This should work already – are you having problems? |
Correct. The import seems to look in the "LAMBDA_TASK_ROOT" for the handler.
|
same error if I use
|
Oh sorry – I thought you were talking about Can you outline the use case again? |
@mhart I have a layer that contains my handler. In my personal use-case, that handler is a wrapper that then does an import and load of another handler... but it's also completely valid for users to have their entire application placed within layers. Example serverless.yml:
|
Oh, this works with existing AWS runtimes? I thought the handler always tried to resolve from |
@mhart The official AWS ones do not for NodeJS, but this is confirmed to work with the official Java and Python runtimes from AWS . I've been nudging AWS to get this working in Node as well... but also, more immediately, seeing if we can get the popular custom Node runtimes to support this (it is already supported in NSolid by Nodesource). |
Hmmm. I'm a little wary of diverging from AWS too much. I could see how absolute paths could be supported, but how do you distinguish between a module called Looking through the AWS Node.js 10 code, it looks like it might support |
My testing has been unsuccessful in using path traversals via '..' to enable this /w the official runtime. Lambda has always supported importing from node_modules, this would ideally just allow importing from /opt/nodejs/node_modules... using the absolute path would be a solution here to avoid unintended consequences; this is already a requirement of the NSolid runtime and would help reduce drift between runtimes. Simply allowing any import via an absolute path (or restricted to the task root and paths beginning with /opt) would suffice for me, and wouldn't cause any breakages moving to this runtime. |
Interesting, this works for me:
|
I haven't updated
|
I'll try that!
On Tue, Jun 11, 2019 at 5:13 PM Michael Hart ***@***.***> wrote:
Interesting, this works for me:
mkdir opt
cd opt
npm install @iopipe/iopipe
cd ..
docker run -v $PWD/opt:/opt lambci/lambda:nodejs10.x ..***@***.***/iopipe.handler
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#20?email_source=notifications&email_token=AAAR354NSVELVEQTO2C7JE3P2AIQPA5CNFSM4HXDFL42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXOQT6Q#issuecomment-501025274>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAR356YRUJNLGLCJDHOSEDP2AIQPANCNFSM4HXDFL4Q>
.
--
-Erica
|
Playing with this more, it seems that the official nodejs10.x runtime now supports the absolute path, but with lambci, I get |
Oh interesting, maybe they’ve updated the nodejs10.x runtime code (finally). Will look into it, thanks for the heads up 👍
…Sent from my iPhone
On Jun 17, 2019, at 8:13 AM, Erica Windisch ***@***.***> wrote:
Playing with this more, it seems that the official nodejs10.x runtime now supports the absolute path, but I get the Cannot find module ***@***.***/iopipe error with lambci (using '../../' doesn't help and would also differ from AWS which errors if I use the .. path traversal)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Oh wow, yeah they've changed a lot of things since the last time I checked. Mostly good! Although it's interesting they've removed the ability to do relative requires. They now throw I'll update this runtime accordingly (and |
It would be useful to be able to load handler modules from layers! (I do this with other runtimes)
Options would be to include /opt/nodejs/node_modules in the search path, or to allow absolute imports.
The text was updated successfully, but these errors were encountered: