serverless-plugin-ignitor

0.1.2 • Public • Published

npm downloads total npm version npm license Build Status

Installation

npm install serverless-plugin-ignitor --save-dev

or

yarn add serverless-plugin-ignitor --dev

Usage

In the serverless file, add serverless-plugin-ignitor within the plugins entry.

Example:

functions:
  hello:
    handler: src/hello.handler
    timeout: 15

plugins:
  - serverless-plugin-ignitor

By default all functions will then be automatically scheduled, wrapped to accept scheduled events, and immediately invoked post-deployment. If you want more granular control, options can be configured within a custom ignitor variable.

Options

The plugin provides the following configurations per matching keys.

Option Values Default Description
schedule Boolean or Object null Controls whether the lambda should be scheduled
wrapper String null The file path where a custom wrapper exists (same as a function handler definition)

Options Example

custom: 
  ignitor:
    hello:
      wrapper: wrappers.logger
      schedule:
        rate: rate(3 minutes)
        enabled: true
        input: 
          source: 'logger'

    # regular expressions can be used
    /good.*/: 
      schedule: false 
      
    /non-matching/:
      schedule: true

functions:
  hello:
    handler: handlers.hello
    timeout: 10
  goodbye:
    handler: handlers.goodbye

plugins:
  - serverless-plugin-ignitor
  - serverless-webpack

Custom Schedule

If you want to build a custom schedule and do not include a custom input event, the default ignitor event will be used.

Custom Wrapper

If you want to build a custom wrapper instead of the default ignitor wrapper, it needs to be written like a higher-order-function.

Example:

// wrappers.js
const logger = (original) => (evt, ctx, cb) => {
  console.log('Logging event data:', JSON.stringify(evt, null, 2));
  return original(evt, ctx, cb);
}

module.exports = {
  logger,
};

Plugin Conflicts

Make sure serverless-plugin-ignitor is placed before any plugins that compile code. Example:

plugins:
  - serverless-plugin-ignitor
  - serverless-webpack

Cost

Cost per execution: $0.0000002

Cost per memory allocated 1024MB: $0.000001667

Calls per day: 288

Calls per month: 8640

Total monthly cost per-lambda: $0.016

**Prices calculated using the following aws information here.

Package Sidebar

Install

npm i serverless-plugin-ignitor

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

14.5 kB

Total Files

9

Last publish

Collaborators

  • jetclosing