static-aws-deploy

command module
v0.0.0-...-27e6812 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

static-aws-deploy

A tool for deploying files to an AWS S3 bucket with configurable headers and invalidating AWS Cloudfront Objects.

Installation

go get github.com/zupzup/static-aws-deploy

Usage

./static-aws-deploy

./static-aws-deploy --silent --config=./data --dry-run --delta

You can use the dry-run option to see which files would be uploaded and which URLs would be invalidated in a real run.

Commandline Options:

  • --config, -c: path to the configuration file (config.yml), default: ./config.yml
  • --dry-run, -dr: run the script without actually uploading or invalidating anything, default: false
  • --silent, -s: omit all log output, default: false
  • --delta, -d: only upload changed files, default: false

Configuration

By default, static-aws-deploy expects a configuration file at ./config.yml which looks like this example (config.dist.yml):

auth:
    accesskey: 'myAccessKey' // AWS Access Key
    key: 'myKey' // AWS Secret Key
s3:
    bucket:
        name: 'myBucket' // unique identifier of the bucket
    parallel: 4 // How many files are uploaded at once
    source: './data' // folder holding the data
    ignore: '\.DS_Store' // regex for files to ignore
    metadata: // list of regex-to-headers mappings, stating which files are uploaded with which headers
        - regex: '\.html?$'
          headers:
              - 'Content-Type': 'text/html'
        - regex: '\.xml$'
          headers:
              - 'Content-Type': 'text/xml'
        - regex: '\.txt$'
          headers:
              - 'Content-Type': 'text/plain'
        - regex: '\.ico$'
          headers:
              - 'Cache-Control': 'public, max-age=31536000'
              - 'Content-Type': 'image/x-icon'
        - regex: '\.jpeg?$'
          headers:
              - 'Cache-Control': 'public, max-age=31536000'
              - 'Content-Type': 'image/jpeg'
        - regex: '\.png$'
          headers:
              - 'Cache-Control': 'public, max-age=31536000'
              - 'Content-Type': 'image/png'
        - regex: '\.gif$'
          headers:
              - 'Cache-Control': 'public, max-age=31536000'
              - 'Content-Type': 'image/gif'
cloudfront:
    distribution: 
        id: 'myDistribution' // id of your cloudfront web distribution
    invalidation: // urls to invalidate
        - '/'
        - '/archive/*'

If you don't provide any invalidation URLs, the invalidation won't be triggered.

The AWS credentials can also be provided via environment variables named AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Warning

Keep in mind, that using this tool to upload files to AWS S3 and/or to invalidate AWS Cloudfront Objects might result in higher costs.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL