Skip to content
A plugin to sync local directories and S3 prefixes for Serverless Framework ⚡️
JavaScript
Branch: master
Clone or download
k1LoW Merge pull request #33 from adastradev/fix-file-metadata-params
Fixes #31 by ignoring the first key (glob).
Latest commit df955c1 Nov 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Initial commit Jul 26, 2017
.eslintrc.js Initial commit Jul 26, 2017
.gitignore Initial commit Jul 26, 2017
README.md update readme Sep 19, 2019
index.js Fixes #31 by ignoring the first key (glob). Sep 27, 2019
package-lock.json Fixes #31 by ignoring the first key (glob). Sep 27, 2019
package.json Fixes #31 by ignoring the first key (glob). Sep 27, 2019

README.md

Serverless S3 Sync npm

A plugin to sync local directories and S3 prefixes for Serverless Framework ⚡️ .

Use Case

  • Static Website ( serverless-s3-sync ) & Contact form backend ( serverless ) .
  • SPA ( serverless ) & assets ( serverless-s3-sync ) .

Install

Run npm install in your Serverless project.

$ npm install --save serverless-s3-sync

Add the plugin to your serverless.yml file

plugins:
  - serverless-s3-sync

Setup

custom:
  s3Sync:
    - bucketName: my-static-site-assets # required
      bucketPrefix: assets/ # optional
      localDir: dist/assets # required
    - bucketName: my-other-site
      localDir: path/to/other-site
      acl: public-read # optional
      followSymlinks: true # optional
      defaultContentType: text/html # optional
      params: # optional
        - index.html:
            CacheControl: 'no-cache'
        - "*.js":
            CacheControl: 'public, max-age=31536000'

resources:
  Resources:
    AssetsBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-static-site-assets
    OtherSiteBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-other-site
        AccessControl: PublicRead
        WebsiteConfiguration:
          IndexDocument: index.html
          ErrorDocument: error.html

Usage

Run sls deploy, local directories and S3 prefixes are synced.

Run sls remove, S3 objects in S3 prefixes are removed.

Run sls deploy --nos3sync, deploy your serverless stack without syncing local directories and S3 prefixes.

sls s3sync

Sync local directories and S3 prefixes.

You can’t perform that action at this time.