I get that I can call a lambda from a another via Nodejs - Invoke an AWS.Lambda function from within another lambda function
What I need to do is call a specific function in another lambda.
So if Lambda_B looks like this:
module.exports = {
doStuffFunction: async (inputData) => {
*do stuff with inputData*
return { outputData }
}
}
in Lambda_A I want to call doStuffFunction(myData)
.
How do I do this?
If they were in the same folder structure, I could do this with a const { doStuffFunction } = require('../Lambda_B')
inside Lambda_A
... but they aren't.
Is creating a layer for utility functions the only way to share those functions?
CodePudding user response:
This is not possible. When an AWS Lambda function is invoked, it will always invoke the same function, which is configured as the Handler Function.
You would need to add additional logic to the function and pass-across information in the event
to help identify what sub-function you would like to call. The AWS Lambda function can then use an if
statement to interpret the event and call the appropriate sub-function.