This is a deployment tool for uploading static websites to S3. If CloudFront is used for hosting the website, the uploaded files can be automatically invalidated in the CloudFront distribution. A prefix tree is used to minimize the number of invalidations since only a limited number of free invalidations are available per month.
The configuration is stored in a YAML file like this:
site: _site
s3_bucket: example.com
cloudfront_distribution_id: XXXXXXXXXXX
cache_rules:
- match: "/assets/*"
maxage: 30 days
- match_regexp: '^assets/image-d{3}-.*.png$'
maxage: 90 days
- match: "/css/*"
maxage: 30 days
- match: "*"
maxage: 1 hourThe site is the directory of the static website relative to the location
of the configuration file. For example, Jekyll will generate the static site
in the _site directory as specified above. If you save the configuration
file as .s3_website.yaml you can simply run s3-deploy-website from the
same directory:
$ cd jekyll-site/
$ ls .s3_website.yaml
.s3_website.yaml
$ s3-deploy-websiteAWS credentials can be provided through the environment variables
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
$ export AWS_ACCESS_KEY_ID=XXXXXX
$ export AWS_SECRET_ACCESS_KEY=XXXXXX
$ s3-deploy-websiteThey can also be provided through the various configuration files that boto reads.
_site for Jekyll sites).s3:GetObject, s3:PutObject, s3:DeleteObject and
s3:ListBucket on the bucket and the keys e.g.
arn:aws:s3:::example.com and arn:aws:s3:::example.com/*.cloudfront:CreateInvalidation.match key specifies a pattern that the rule applies to. This uses
glob-style matching (with * and ?). Matching can also be performed
with regular expressions by using match_regexp. Only the
first rule to match a given key will be used. The maxage key
specifies the time to cache the file. The value should be either a number
of seconds or a string like 30 days, 5 minutes, 30 seconds, etc.The configuration in .s3_website.yaml was inspired by s3_website although
the options supported by s3_website are slightly different.
MIT.