@nrfcloud/s3-sync-dir

Utility to sync local dir to s3 bucket

Usage no npm install needed!

<script type="module">
  import nrfcloudS3SyncDir from 'https://cdn.skypack.dev/@nrfcloud/s3-sync-dir';
</script>

README

s3-sync-dir

Utility script to automate syncing a local dir to an s3 bucket

Usage

By default this script walks the user through the decisions to create a release. It also has an option to send in all the options at once (no prompt). The following is an example of the available options. You can get this output by running npx s3-sync-dir --help.

Usage: index.ts [options]

Options:
  -k, --access-key-id <accessKeyId>          AWS Access Key ID
  -s, --secret-access-key <secretAccessKey>  AWS Access Key Secret
  -r, --region <region>                      AWS Region
  -b, --bucket <bucket>                      S3 Bucket
  -d, --dir-to-sync <dirToSync>              Dir to Sync
  -p, --basePath <path>                      Base path for directory
  -g, --debug                                Debug
  -h, --help                                 output usage information

# example
npx s3-sync-dir -d "local-dir" -b "s3-bucket" -p "/absolute/base/path (optional)"

Configuration

This script automatically looks for a .env file at the project root. The repo includes a .env.sample file. To use with your project, run cp node_modules/s3-sync-dir/.env.sample ./.env. The file includes the following config variables:

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=

The script will fall back to the variables defined in the .env file, if not passed in explicitly as arguments.

Gotchas

The S3 bucket must be already created and grant write permissions to the owner of the AWS credentials.