Run lambda function as child process
npm install lambda-spawnRun lambda function as child process.
```
npm i lambda-spawn
` javascript
const {
INVOKE_RESULT,
spawnLambda,
} = require('lambda-spawn');
const options = {
handler: 'index.handler',
moduleDir: 'path/to/lambda',
};
const lambdaProcess = spawnLambda(options, event, context);
lambdaProcess.on(INVOKE_RESULT, ({ result }) => {
});
`
- options.arnoptions.dir
- An ARN that identify a lambda process.
- process.cwd()
- A current directory of the lambda process.
- Default: options.handler
- index.handler
- Names of a module and a function.
- Default: options.env
- process.env
- An object of environment variables that is used to launch a lambda process.
- Default: options.lambdaEnv
- options.env
- An object of environment variables that is used as the lambda configuration.
- This object is merged to .options.moduleDir
- options.typescript
- A path of a directory that the lambda function is located.
- ts-node
- If this option is truthy, is used to launch a lambda process.event
- context
- An event object that is used to invoke the lambda function.
-
- A context object that is used to invoke the lambda function.
#### Properties
- arnspawnLambda
- An ARN that is passed to .
#### Event: lambda.INVOKE_RESULT
The lambda.INVOKE_RESULT event is emitted when the lambda function returns the result.
This event passes a message object to a listener. The message object has following properties:
- errresult`
- An Error object when the lambda function returns an error.
-
- A result that is returned by the lambda function.
MIT