Closed dblock closed 7 years ago
Found the problem, looks like module.exports = app;
is causing this. What's the recommended way to combine alexa-app-server and lambda? I am trying to use alexa-app-server in development and use apex to deploy the function to lambda.
Can make it work with some ENV settings, but seems ugly.
if (process.env['LAMBDA_FUNCTION_NAME'] != null) {
console.log("AWS lambda")
exports.handle = app.lambda();
} else if (process.env['ENV'] == 'development') {
console.log("Development Mode")
module.exports = app;
} else {
var fs = require('fs');
fs.writeFileSync('schema.json', app.schema());
fs.writeFileSync('utterances.txt', app.utterances());
console.log('Schema and utterances exported!');
}
@dblock the module.exports = app
will make a handler
function available on the export automatically so you can do this in lambda as well. Your issue is probably that you're using handle
instead of handler
in your lambda function definition.
You can also do exports.handle = app.lambda()
regardless of whether this is running in a lambda context or not.
@ajcrites Are you saying I can collapse my dev mode with lambda mode in https://github.com/artsy/elderfield/blob/master/functions/artsy/index.js#L123?
This needs more thorough README. I'm going to close this for now though.
I've notice that deploying with Apex changes the handler to "index.handle" where all the sdk examples uses handler. For this you'll want to modify Apex's project.json and add "handler":"index.handler"
@thegregthomp Can you please PR any doc changes?
@dblock for me this is kind of an edge case in that you'd need to be using Apex for lambda deployments. I'm not sure that's worthy of a note in the docs because I'm not sure how many people actually deploy this way. If you feel it's a lot of people, I can do that.
Not sure, your call. I think lots of people use Apex, we do - http://artsy.github.io/blog/2016/11/30/bringing-artsy-to-amazon-echo-alexa/
I was just in the AWS console a moment ago. I created a new lambda function via the console. In the function configuration tab, the handler was set to index.handle
(NO r
) by default. However the boilerplate code provided for the lambda function had exports.handler
(WITH r
). This was a brief source of confusion for me
If something can be better documented, please PR!
I am sure this is a noob problem (sorry if it is), code in https://github.com/dblock/elderfield. The code works locally just fine, including if I download it from Lambda and run locally, but once on Lambda I get this:
It's something in my alexa-app, because if stub that code with an apex hello world example that works. Can't find logs or anything else that helps :(
Halp!