0.1.2 • Published 5 years ago

serverless-plugin-ignitor v0.1.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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.

OptionValuesDefaultDescription
scheduleBoolean or ObjectnullControls whether the lambda should be scheduled
wrapperStringnullThe 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.