Which serverless and serverless-offline version are you using ? Try v3.33.0
Also check your serverless.yml file for typos :)
Using Serverless 1.36.0 and serverless-offline 3.32.2.
I tried 3.33.0, but still same behavior.
Response is like:
{"statusCode":404,"error":"Serverless-offline: route not found.","currentRoute":"get - /hello","existingRoutes":[]}
What about your serverless.yml file ?
As the blog post describes (so that I can specify NodeJS 10), the serverless.yml looks like:
plugins:
- serverless-webpack
- serverless-offline
provider:
name: aws
# runtime: nodejs8.10
runtime: provided
functions:
hello:
handler: handler.hello
events:
- http:
method: get
path: hello
layers:
- arn:aws:lambda:us-east-1:553035198032:layer:nodejs10:4
I see. The plugin does not support a provided runtime yet. But I'm confident it will in the future. Thank you for your issue.
@dherault if you are using a custom runtime, in my case PHP, though a Lambda layer providing the binary and boostrap file, is it possible to make use of this plugin to emulate api gateway and lambda up to the point where the binary is executed?
The custom binary has been setup in a similar way to https://aws.amazon.com/blogs/apn/aws-lambda-custom-runtime-for-php-a-practical-example/ but with all layers configured inside the serverless.yml.
(serverless-offlineworks great standard runtimes 馃憤)
@BenEllerby I'm sorry but the plugin can't do that. It looks like serverless-offline will not handle provided runtimes until serverless can invoke them.
OK @dherault thanks for the help 馃憤
@awhitford just had the same problem.
as an interim, you can use serverless variables, e.g.
provider:
runtime: ${self:custom.runtime.${env:NODE_ENV}} # or ${opt:stage} alternatively
custom:
runtime:
localhost: nodejs8.10 # even just "nodejs" works
development: provided
production: provided
serverless-offline doesn't care which node version you really run locally. it only uses the runtime parameter to distinguish between the supported node.js, python, and ruby runtimes.
@dherault I wonder if it would be a good idea for serverless-offline to use custom options (same as for port, prefix etc.) to support runtime: provided until it's fully supported?
e.g. something along those lines:
provider:
runtime: provided
custom:
serverless-offline:
port: 8300
runtime-provided: nodejs # this option should be allowed to be set only if the provider runtime option is set to: provided
Hello @dnalborczyk that is a nice idea! We would gladly accept a PR implementing this. I'll put it on my check list for in case I get a few minutes to work on it.
I did it. You can now set the providedRuntime CLI option or put it under custom.serverless-offline.providedRuntime. v4.4.2
@dherault nice! thank you!! just installed it and it works great!
Serverless can now invoke provided runtimes, I think as of this PR: https://github.com/serverless/serverless/pull/5863
Would it therefore be possible to make Serverless Offline work with other provided runtimes, like PHP?
Is there anything I could do? I would really like to run a local APIGateway server for my PHP lambda functions, and am more than happy to help with a PR.
Hi @harmenjanssen , I don't think a PR on the subject would be that easy since we don't use docker in the first place... But you can try !
Ha, I was hoping for a little more strategy. 馃槈
Above you indicate that "It looks like serverless-offline will not handle provided runtimes until serverless can invoke them.".
I was hoping, based on that statement, that now that Serverless _does_ invoke provided runtimes, you already had an idea of how to integrate?
@dherault I Took a look and found out that it is fairly easy to support provided runtimes.
I Could make a PR if you think it's worth it.
https://github.com/mnapoli/bref/issues/320#issuecomment-488717167
I Could make a PR if you think it's worth it.
@atrope absolutely, do it!!
@dnalborczyk can you please have a look in the PR and help testing it?
@atrope yes, will do! probably later today ...
@atrope I got it running yesterday, and generally, it seems to work. although I noticed a couple things which might need some changes or fixes, and I'm not sure about the expectations and the work flow in general. that might be better answered by @dherault . I'll try to write some comments later today in the PR.
Most helpful comment
@dherault I Took a look and found out that it is fairly easy to support provided runtimes.
I Could make a PR if you think it's worth it.
https://github.com/mnapoli/bref/issues/320#issuecomment-488717167