Sync a directory to S3, including metadata for specific files.


Keywords
aws, s3
License
MIT
Install
npm install @skgrush/sync-s3@0.1.0-rc.4

Documentation

@skgrush/sync-s3

Little tool for syncing files into an S3 bucket.

Expects that all files in the copySourceDirectory should replace all the files in the S3 bucket, and synchronizes them lazily based on MD5 hashes.

The main motivation for this project over AWS's official sync is I wanted to set metadata on specific files and the multi-sync approach made no sense to me.

Usage

env.json

{
  "$schema": "./dist/env.schema.json",
  "region": "us-east-2",
  "bucket": "BUCKET-NAME",
  "credentials": {
    "accessKeyId": "AWS-S3-WRITABLE-KEY-ID",
    "secretAccessKey": "AWS-S3-WRITABLE-ACCESS-KEY"
  },
  "copySourceDirectory": "../dist/MY-PROJECT-NAME/browser",
  "metadataFile": "../metadata.json"
}

metadata.json

{
  "some/file.jpeg": {
    "CacheControl": "no-cache"
  },
  "no-extension": {
    "ContentType": "application/javascript"
  },
  "go-elsewhere": {
    "WebsiteRedirectLocation": "https://github.com/skgrush"
  }
}
npx @skgrush/sync-s3 --execute env.json