coreylight / serverless-plugin-iopipe

Automatically wrap your serverless framework functions with IOpipe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IOpipe Serverless Framework Plugin (Beta)

serverless CircleCI

A serverless plugin to automatically wrap your functions with iopipe.

Requirements

  • Node >= 4.3.2
  • NPM >= 2.14.12
  • Yarn >= 0.22.0 (optional)
  • A valid package.json file
  • A valid serverless.yml file

Install

With yarn (recommended):

yarn add iopipe
yarn global add serverless-plugin-iopipe

With npm:

npm install iopipe
npm install serverless-plugin-iopipe -g

Add the plugin to your serverless.yml file:

plugins:
  - serverless-plugin-iopipe

Add your IOpipe project token within the "custom" config in serverless.yml. Where is the token?

custom:
  iopipeToken: YOUR_TOKEN HERE

You're set! The plugin will run during an sls deploy.

How Does it Work?

serverless-plugin-iopipe wraps the function handlers defined in serverless.yml with IOpipe so you don't have to. It allows you to deploy and upgrade multiple functions simultaneously.

It's powered by the the excellent jscodeshift. The plugin examines each handler and modifies the code only within the deployment package if it needs to.

Options

All options are set in the "custom" config in serverless.yml. See Example

iopipeToken (required)

The token (clientId) of the project you would like to wrap your functions with.

iopipeNoVerify (optional)

Skip a check that ensures iopipe is installed via npm/yarn and present in package.json

iopipeNoUpgrade (optional)

The plugin automatically upgrades the IOpipe library to the latest available version that satisfies the semver range specified in package.json. Use this option to disable that feature.

iopipeNoYarn (optional)

When auto-upgrading, Yarn will be used in place of NPM if a yarn.lock file is found. Use this flag disable yarn and use NPM to upgrade the iopipe library.

iopipeExclude (optional)

Exclude certain functions from the plugin. Comma separated string.

iopipePlaceholder (optional)

Use process.env.IOPIPE_TOKEN as a placeholder variable to allow the token to be configured via environment variables in Serverless, AWS CLI, or AWS Console instead of embedding the token string directly.

iopipePreferLocal (optional)

It's highly recommended you install this plugin globally instead of per-project. If installed locally, your Serverless bundle may be much larger than you'd like. However, if you're sure you want to use a local copy of serverless-plugin-iopipe, use this option to skip the global check.

Known Issues

  • This plugin attempts to skip handlers that are already wrapped, but edge cases my arise, especially if you require the iopipe module outside of the handler file.
  • If your package.json is located in a non-standard place, auto-upgrading may not work.
  • If attempting to use es6 modules natively i.e. export function handler..., may not work.

Support

File an issue here, hit us up on Slack, or send us a note at support@iopipe.com

About

Automatically wrap your serverless framework functions with IOpipe


Languages

Language:JavaScript 100.0%