Git Product home page Git Product logo

s3deploy's Introduction

s3deploy

GoDoc

A simple tool to deploy static websites to Amazon S3 with Gzip and custom headers support (e.g. "Cache-Control").

Install

s3deploy is a Go application. The easiest way to intall it is via go get:

 go get -v github.com/bep/s3deploy

Note that s3deploy is a perfect tool to use with a continuous integration tool such as CircleCI. See this static site for a simple example of automated depoloyment of a Hugo site to Amazon S3 via s3deploy. The most relevant files are circle.yml and .s3deploy.yml.

Use

Usage of s3deploy:
  -bucket string
    	Destination bucket name on AWS
  -force
    	upload even if the etags match
  -h	help
  -key string
    	Access Key ID for AWS
  -region string
    	Name of region for AWS (default "us-east-1")
  -secret string
    	Secret Access Key for AWS
  -source string
    	path of files to upload (default ".")
  -workers int
    	number of workers to upload files (default -1)

Note: key and secret can also be set in environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Advanced Configuration

Add a .s3deploy.yml configuration file in the root of your site. Example configuration:

routes:
    - route: "^.+\\.(js|css|svg|ttf)$"
      #  cache static assets for 20 years
      headers:
         Cache-Control: "max-age=630720000, no-transform, public"
      gzip: true
    - route: "^.+\\.(png|jpg)$"
      headers:
         Cache-Control: "max-age=630720000, no-transform, public"
      gzip: true
    - route: "^.+\\.(html|xml|json)$"
      gzip: true   

Example IAM Policy

{
   "Version": "2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListBucket",
            "s3:GetBucketLocation"
         ],
         "Resource":"arn:aws:s3:::<bucketname>"
      },
      {
         "Effect":"Allow",
         "Action":[
            "s3:PutObject",
            "s3:PutObjectAcl",
            "s3:DeleteObject"
         ],
         "Resource":"arn:aws:s3:::<bucketname>/*"
      }
   ]
}

Replace with your own.

Background Information

If you're looking at s3deploy then you've probably already seen the aws s3 sync command - this command has a sync-strategy that is not optimised for static sites, it compares the timestamp and size of your files to decide whether to upload the file.

Because static-site generators can recreate every file (even if identical) the timestamp is updated and thus aws s3 sync will needlessly upload every single file. s3deploy on the other hand checks the etag hash to check for actual changes, and uses that instead.

Alternatives

  • go3up by Alexandru Ungur
  • s3deploy by Nathan Youngman (the starting-point of this project)

s3deploy's People

Contributors

bep avatar mistobaan avatar nathany avatar oodavid avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.