0.0.3 • Published 7 years ago

s3-copy v0.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

S3 Copy

A tool used to copy files from S3.

Requirements

  • NodeJS v7.x

Installation

npm install -g s3-copy

AWS REGION

You must export the AWS region you are deploying your service to, or supply it via the -r parameter.

export AWS_REGION=us-east-1

AWS Credentials

The tool will use the standard credential chain used by other aws cli tools.

If you wish to supply credentials manually see Options

How it works

AWS Setup

  • Give a user or role access to this key via the key's policy

By default, the tool will use the default credential chain for AWS.

You can specify Access Keys and Secret Access keys via Environment variables, or cli arguments. If you are running the tool on an EC2 instance, the instance profile will be used.

Usage

Usage: s3-copy [options] [command]


  Commands:

    copy [bucket] [key] [outputFile] Copies a file from an S3 Bucket to the specified local path.

  Options:

    -h, --help                        output usage information
    -V, --version                     output the version number
    -k, --access-key-id <id>          AWS Access key ID. Env: $AWS_ACCESS_KEY_ID
    -s, --secret-access-key <secret>  AWS Secret Access Key. Env: $AWS_SECRET_ACCESS_KEY
    -r, --region <region>             AWS Region. Env: $AWS_REGION
    -p, --profile <name>              AWS Credential profile to use

Exporting AWS Region

An AWS Region must be specified when running s3-copy. It can be provided via the --region parameter or with the following export:

export AWS_REGION=us-east-1

The above command will set your region to us-east-1

Copying a file from S3

To copy a file from S3 to your local drive:

$ s3-copy copy [bucket] [key] [outputFile]

Let's copy a file from S3:

  • Bucket Name: Test-Bucket
  • Key Name: Test.txt
  • Output Location: ~/Test.txt
$ s3-copy copy Test-Bucket Test.txt ~/Test.txt

The file will be copied to ~/Test.txt

Optional Parameters

AWS Credentials

To supply credentials manually you can use the following parameters:

  • --access-key-id - To specify your access key ID
  • --secret-access-key - To specify your secret
  • --region - To specify the AWS Region

Using Profiles

Alternatively you can supply an AWS credential profile to use via:

  • --profile - To use a credential profile instead of supplying access key and secret