https://github.com/zupzup/static-aws-deploy
A tool for deploying files to an AWS S3 bucket with configurable headers and invalidating AWS Cloudfront Objects.
https://github.com/zupzup/static-aws-deploy
aws aws-s3 cloudfront deployment static-site
Last synced: 4 months ago
JSON representation
A tool for deploying files to an AWS S3 bucket with configurable headers and invalidating AWS Cloudfront Objects.
- Host: GitHub
- URL: https://github.com/zupzup/static-aws-deploy
- Owner: zupzup
- License: apache-2.0
- Created: 2016-12-15T19:10:30.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2020-08-10T11:17:01.000Z (over 5 years ago)
- Last Synced: 2025-07-08T04:59:35.206Z (7 months ago)
- Topics: aws, aws-s3, cloudfront, deployment, static-site
- Language: Go
- Homepage:
- Size: 116 KB
- Stars: 28
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# static-aws-deploy
A tool for deploying files to an AWS S3 bucket with configurable headers and invalidating AWS Cloudfront Objects.
## Installation
```
go get github.com/zupzup/static-aws-deploy
```
## Usage
```
./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`
## Configuration
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`.
## Warning
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.