Created
January 21, 2019 22:32
-
-
Save Daveiano/1862a4773e47ceaa9f8a35188b0e7357 to your computer and use it in GitHub Desktop.
Basic Sync Script for AWS S3 for a static website bucket with Cloudfront Cache invalidation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Should be in Format: Wed, 21 Oct 2015 07:28:00 GMT | |
expire_date=$(date +"%a, %d %b %Y 16:00:00 GMT" -d '+ 1 month') | |
# Sync Assets, max-age = 1 month, expires header set now + 1 month | |
aws s3 sync ./.. s3://<bucket> --exclude '*' --include 'favicon.ico' --include 'dist/*' --include 'index.html' --cache-control 'public, max-age=2592000' --expires "$expire_date" --delete | |
# Cloudfront Cache Invalidation | |
aws cloudfront create-invalidation --distribution-id <ID> --paths '/*' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment