@growsari/invoke-lambda

1.0.4 • Public • Published

Invoke Lambda Package

Utility function for calling microservices within APIs.

Usage

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.

Async

await invokeLambda('ms-some-project', 'create', { name: 'some-name', description: 'some-value'}, {async: true})

You can specify {async: true} to execute lambda asynchronously.

Details

Invokes the lambda named [service]-[stage]-[operation].

Assumptions

  • process.env.AWS_DEFAULT_REGION is named in the project.
  • process.env.IS_OFFLINE is true 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.

Errors

Code Message
INVOKE-001 Invalid lambda function 'function_name'
INVOKE-002 Error executing lambda 'function_name'

Dependents (1)

Package Sidebar

Install

npm i @growsari/invoke-lambda

Weekly Downloads

181

Version

1.0.4

License

ISC

Unpacked Size

4 kB

Total Files

3

Last publish

Collaborators

  • gs.dwight.badua
  • leland.growsari
  • melyo
  • prasad.riktam
  • ddimaano.gs
  • madhugogineni