Last active
November 7, 2022 21:44
-
-
Save naftulikay/7bcf6d0ed1d41cfb81d72a7d32981c33 to your computer and use it in GitHub Desktop.
Sync a directory to S3 and invalidate the CloudFront cache for changed resources.
This file contains 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 | |
# output format is like this: | |
# upload: index.html to s3://$BUCKET/index.html | |
# | |
# so we grab the second item which is the file path and pass that via xargs to the | |
# cloudfront invalidation command | |
aws s3 sync --sse AES256 s3://$BUCKET/ site/ | awk '{print $2;}' | \ | |
xargs aws cloudfront create-invalidation --distribution-id $CF_DISTRO_ID --paths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment