Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deply hugo static site to AWS s3
#!/bin/bash
set -e
DISTRIBUTION_ID=E1TOB0026XX0U7
BUCKET_NAME=thatopsguy.com
hugo -v
# Copy over pages
aws s3 sync --acl "public-read" --sse "AES256" public/ s3://$BUCKET_NAME/ --exclude 'img' --exclude 'js' --exclude 'css' --exclude 'post'
# Ensure static files are set to cache forever - cache for a month --cache-control "max-age=2592000"
aws s3 sync --cache-control "max-age=2592000" --acl "public-read" --sse "AES256" public/img/ s3://$BUCKET_NAME/img/
aws s3 sync --cache-control "max-age=2592000" --acl "public-read" --sse "AES256" public/css/ s3://$BUCKET_NAME/css/
aws s3 sync --cache-control "max-age=2592000" --acl "public-read" --sse "AES256" public/js/ s3://$BUCKET_NAME/js/
# Invalidate landing page so everything sees new post.
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths /index.html /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.