Utility function for calling microservices within APIs.
const invokeLambda = require('@growsari/invoke-lambda')
await invokeLambda('ms-some-project', 'create', { name: 'some-name', description: 'some-value'})
You may specify the API version and the region as named parameters after params
. They will default to '2015-03-31'
and process.env.AWS_DEFAULT_REGION
respectively, if not defined.
await invokeLambda('ms-some-project', 'create', { name: 'some-name', description: 'some-value'}, {async: true})
You can specify {async: true} to execute lambda asynchronously.
Invokes the lambda named [service]-[stage]-[operation]
.
-
process.env.AWS_DEFAULT_REGION
is named in the project. -
process.env.IS_OFFLINE
istrue
when deployed. - When in offline mode, it is deployed through Docker deployment.
-
process.env[``${service.toUpperCase()}-PORT``]
is assigned to the deployment port of the specific service in the Docker deployment. - The containing lambda has access to all of the lambdas named.
- Called function response has the following payload format
{
data: Object,
success: Boolean,
message: String,
code: any
}
so that the response will be identified properly as a success or a failure.
Code | Message |
---|---|
INVOKE-001 | Invalid lambda function 'function_name' |
INVOKE-002 | Error executing lambda 'function_name' |