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 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
Credentials
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
They can also be provided through the various configuration files that boto reads.
Configuration file
- site
The directory of the static content to be uploaded (relative to the location of the configuration file (e.g. _site for Jekyll sites).
- s3_bucket
The name of the S3 bucket to upload the files to. You have to allow the actions 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/*.
- s3_reduced_redundancy
An optional boolean to indicate whether the files should be uploaded to reduced redundancy storage.
- cloudfront_distribution_id
The CloudFront distribution to invalidate after uploading new files. Only files that were changed will be invalidated. You have to allow the action cloudfront:CreateInvalidation.
- cache_rules
A list of rules to determine the cache configuration of the uploaded files. The 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.
- endpoint_url
(Optional) For setting custom endpoint for boto3: Boto3 Session reference
Similar software
The configuration in .s3_website.yaml was inspired by s3_website although the options supported by s3_website are slightly different.
Licence
MIT.
Metadata
Release files for s3-deploy-website 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| s3-deploy-website-0.3.0.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| s3_deploy_website-0.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 28.1 kB
Release files / s3-deploy-website-0.3.0.tar.gz
| Download URL | s3-deploy-website-0.3.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf6497f0c8c1c08d41412ce2feaf1fb00e6aa5082ae6bcc9e79cbddde0a0fa5b
|
|
BLAKE2b-256 checksum How to use checksums |
a9cfeaa6c7960291c2a2a4d19f980ab8ad93f9cf17a98439b319b851189bb45e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14
|
Release files / s3_deploy_website-0.3.0-py2.py3-none-any.whl
| Download URL | s3_deploy_website-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
db90f162fa230b1d4b2f33f32ab6d8b5998333309f6c073214247ec85dbbd387
|
|
BLAKE2b-256 checksum How to use checksums |
6a52f0ff6fb0e9af333413edbd27d473024a6f509d1cdcdf40b91e67055b8c64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14
|