Skip to content

yury-sannikov/go-cloudfront-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-cloudfront-deploy

Deploy static web sites to AWS CloudFront

Installation

  • Install Go using this url
  • Configure Go
  • Check path having go/bin folder listed as export PATH=$PATH:$GOPATH/bin
  • go install github.com/yury-sannikov/go-cloudfront-deploy
  • You should have $GOPATH/bin/go-cloudfront-deploy executable installed and accessible from command line

Usage

AWS_ACCESS_KEY_ID and WS_SECRET_ACCESS_KEY environment variables should be set or EC2 role should be enforced in order to make successfull call to AWS API. If you don't have credentials, go here

go-cloudfront-deploy [ACTION LIST] [OPTIONS]
Action List:
    clean          Clean S3 bucket content before upload any data
    s3             Upload files from specified location to s3 bucket
    cloudfront     Create cloudfront distribution or if any, invalidate it to use new content

Application Options:
-b, --bucket_name= S3 bucket name
-r, --region=      S3 region
-p, --path=        Path to folder for upload from

Help Options:
-h, --help         Show this help message

Action list can contain all of the actions, or some of them, for instance

go-cloudfront-deploy clean s3 cloudfront -b site.com -r us-west-1 -p ~/build/site.com

Which is equivalent to this:

go-cloudfront-deploy clean s3 -b site.com -r us-west-1 -p ~/build/site.com
go-cloudfront-deploy s3 -b site.com -r us-west-1 -p ~/build/site.com
go-cloudfront-deploy cloudfront -b site.com -r us-west-1 -p ~/build/site.com

How it works

clean

Scan all files in a bucket in batches of 1000 items and delete it.

s3

  • Create new bucket if none exists
  • Attach security policy to allow s3:Get for all users
  • Enable static web site hosting
  • Upload in parallel files from folder
  • Set up correct mime types
  • Set up cache control headers

cloudfront

  • Check CloudFront distribution using SiteBuilderCloudfrontID tag of correspondent S3 bucket
  • If bucket has no distribution, create new one
  • If distribution exists, invalidate all objects using /* pattern

About

Deploy static web sites to AWS CloudFront

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages