A tool for deploying files to an AWS S3 bucket with configurable headers and invalidating AWS Cloudfront Objects.
go get github.com/zupzup/static-aws-deploy
./static-aws-deploy
./static-aws-deploy --silent --config=./data --dry-run --delta
You can use the dry-run
option to see which files would be uploaded and which URLs would be invalidated in a real run.
Commandline Options:
--config, -c
: path to the configuration file (config.yml), default:./config.yml
--dry-run, -dr
: run the script without actually uploading or invalidating anything, default:false
--silent, -s
: omit all log output, default:false
--delta, -d
: only upload changed files, default:false
By default, static-aws-deploy
expects a configuration file at ./config.yml
which looks like this example (config.dist.yml
):
auth:
accesskey: 'myAccessKey' // AWS Access Key
key: 'myKey' // AWS Secret Key
s3:
bucket:
name: 'myBucket' // unique identifier of the bucket
parallel: 4 // How many files are uploaded at once
source: './data' // folder holding the data
ignore: '\.DS_Store' // regex for files to ignore
metadata: // list of regex-to-headers mappings, stating which files are uploaded with which headers
- regex: '\.html?$'
headers:
- 'Content-Type': 'text/html'
- regex: '\.xml$'
headers:
- 'Content-Type': 'text/xml'
- regex: '\.txt$'
headers:
- 'Content-Type': 'text/plain'
- regex: '\.ico$'
headers:
- 'Cache-Control': 'public, max-age=31536000'
- 'Content-Type': 'image/x-icon'
- regex: '\.jpeg?$'
headers:
- 'Cache-Control': 'public, max-age=31536000'
- 'Content-Type': 'image/jpeg'
- regex: '\.png$'
headers:
- 'Cache-Control': 'public, max-age=31536000'
- 'Content-Type': 'image/png'
- regex: '\.gif$'
headers:
- 'Cache-Control': 'public, max-age=31536000'
- 'Content-Type': 'image/gif'
cloudfront:
distribution:
id: 'myDistribution' // id of your cloudfront web distribution
invalidation: // urls to invalidate
- '/'
- '/archive/*'
If you don't provide any invalidation URLs, the invalidation won't be triggered.
The AWS credentials can also be provided via environment variables named AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
.
Keep in mind, that using this tool to upload files to AWS S3 and/or to invalidate AWS Cloudfront Objects might result in higher costs.