3
votes

I am using serveless + aws + node.js.

I have a lambda calling another lambda. I can't get to run the lot locally. I can invoke both lambdas locally with 'serverless invoke local -f ...' BUT
the caller one comes back with:

{"message":"Function not found: arn:aws:lambda:eu-west-1:5701xxxxxxxxxx:function:the-right-function-name"}

as if the caller function invoked the callee on AWS and not locally.

Is there anyway to do stay local and if yes, what may I be missing?

1

1 Answers

1
votes

You can achieve that with this plugin. There is a feature of AWS SDK for Lambda that allows you to override the API endpoint of Lambda service. Therefore you can set it to localhost.

const AWS = require('aws-sdk');

const endpoint = process.env.SERVERLESS_SIMULATE ?
  process.env.SERVERLESS_SIMULATE_LAMBDA_ENDPOINT :
  undefined

const lambda = new AWS.Lambda({ endpoint })

For more details, refer to the plugin's readme. Also there is a nice article about that.