Ini adalah alat penempatan untuk mengunggah situs web statis ke S3. Jika CloudFront digunakan untuk hosting situs web, file yang diunggah dapat secara otomatis dibatalkan dalam distribusi CloudFront. Pohon awalan digunakan untuk meminimalkan jumlah pembatalan karena hanya sejumlah pembedahan yang terbatas yang tersedia per bulan.
Konfigurasi disimpan dalam file YAML seperti ini:
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 hour
The 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-website
AWS 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-website
Mereka juga dapat disediakan melalui berbagai file konfigurasi yang dibaca Boto.
_site
for Jekyll sites).s3:GetObject
, s3:PutObject
, s3:DeleteObject
and s3:ListBucket
on the bucket and the keys eg 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
. Hanya aturan pertama yang mencocokkan kunci yang diberikan akan digunakan. 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.