A thin task wrapper around @goserverless
Switch branches/tags
Nothing to show
Clone or download
rajwilkhu Merge pull request #8 from vitorrm/master
[Issue 4] Fixing multiwords command
Latest commit 3de29e9 Aug 27, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
commands [Issue 3] Fixing multiwords command Aug 21, 2017
.gitignore Initial commit Mar 18, 2017
.npmignore Setup project dependencies Mar 18, 2017
LICENSE Initial commit Mar 18, 2017
README.md Fixed typo in README Mar 19, 2017
index.js Send the file to the next pipe Jul 25, 2017
package.json Send the file to the next pipe Jul 25, 2017



A simple wrapper around serverless 1.x that simplifies the creation of gulp tasks. If you like having all your automation tasks for local and CI in one place eg running unit, acceptance and smoke tests, environment or config specific stuff, and deployment of lambdas, etc and love the simplicity that gulp brings, then this module may help you. Some examples of using gulp with serverless spawn a process with options as arguments to serverless. The approach used by this module uses serverless framework as a node module and provides options to it via your gulpfile.

To get started, npm install this module as a dev dependency:

npm install --save-dev serverless-gulp

This module has a dependency on the following modules:

  • serverless 1.x
  • gulp
  • gulp-util for logging

Once installed, unless you need other gulp task modules, you should not really need any other dev dependencies. Copy the gulpfile below to get started and keep developing your services as you would. To get started, use the code below as your initial gulpfile.js. The idea of this module is to keep things simple, so regardless of how the serverless framework evolves, this module will allow you to specify any command and and options within a gulp task as you would on the command line.

const gulp = require('gulp');
const serverlessGulp = require('serverless-gulp');
const util = require('gulp-util');

const paths = {
  serverless: ['./**/serverless.yml', '!node_modules/**/serverless.yml']

gulp.task('deploy', () => {
  gulp.src(paths.serverless, { read: false })
      .pipe(serverlessGulp.exec('deploy', { stage: 'dev' }));

gulp.task('remove', () => {
  gulp.src(paths.serverless, { read: false })
    .pipe(serverlessGulp.exec('remove', { stage: 'dev' }));

The first argument to serverless-gulp is the command you would pass to serverless framework, eg deploy, invoke, etc; the second takes options for the command. So, for the following command line:

serverless invoke --function someFunction --stage en --region eu-west-2

your gulp task would look something like:

gulp.task('invoke', () => {
  gulp.src(paths.serverless, { read: false })
    .pipe(serverlessGulp.exec('invoke', { function: 'someFunction', stage: 'en', region: 'eu-west-1' }));

Installing serverless modules

If you are writing your serverless services in nodejs, then you have to install node modules for each service. You can provide a post install hook in your main npm package to install packages for every service as follows:

Include the following gulp task in your gulpfile.js:

gulp.task('setup', () => {

Include the following post install step in the package.json

  "scripts": {
    "postinstall": "gulp setup"

Example project

For a working example, or as a quick start project, fork/copy the repo at https://github.com/rhythminme/serverless-gulp-example