JSPM

  • Created
  • Published
  • Downloads 31130
  • Score
    100M100P100Q146972F
  • License MIT

Serverless s3 local plugin

Package Exports

  • serverless-s3-local

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-s3-local) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

serverless-s3-local

serverless-s3-local is a Serverless plugin to run S3 clone in local.
This is aimed to accelerate development of AWS Lambda functions by local testing.
I think it is good to collaborate with serverless-offline.

Installation

npm install serverless-s3-local --save-dev

Example

serverless.yaml

service: serverless-s3-local-example
provider:
  name: aws
  runtime: nodejs4.3
plugins:
  - serverless-s3-local
  - serverless-offline
custom:
  s3:
    port: 8000
    buckets:
      - local-bucket
    directory: /tmp
    cors: false
functions:
  webhook:
    handler: handler.webhook
    events:
      - http:
          method: GET

handler.js

const AWS = require('aws-sdk');
module.exports.webhook = (event, context, callback) => {
  const S3 = new AWS.S3({
    s3ForcePathStyle: true,
    endpoint: new AWS.Endpoint('http://localhost:8000'),
  });
  S3.putObject({
    Bucket: 'local-bucket',
    Key: '1234',
    Body: new Buffer('abcd')
  }, () => {} );
};

Feature

  • Start local S3 server with specified root directory and port.
  • Create buckets at launching.

See also

License

This software is released under the MIT License, see LICENSE.txt.