How to Resolve Serverless error: lambda is not a function

Sharing is Caring

For those not aware, the serverless framework is amazing for abstracting away a lot of the differences between AWS, Azure, and the other cloud providers. The serverless framework works by having a common building, compiling and transporting code in a consistent manner to the relevant cloud provider. It can even use CloudFormation stacks to create and provision resources within AWS.

When trying to invoke any of your lambda functions if you are getting an error that says “lambda is not a function” the problem is likely that the handler is misspelled in the serverless.yml file OR you aren’t exporting modules.exports.handler and are instead exporting something else.

In the serverless.yml file make sure that the case matches exactly how the handler and file system are named. For example, if your function is located in /functions/my-function.js and exports module.exports.handler than the path is likely wrong because of case sensitivity or spelling.

Sharing is Caring