37 lines
824 B
Bash
37 lines
824 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
readonly thisDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
readonly rootDir="$(dirname "${thisDir}")"
|
||
|
|
||
|
main() {
|
||
|
SECONDS=0
|
||
|
echo "copying files to S3..."
|
||
|
aws s3 cp --recursive --acl public-read "${rootDir}/public/" s3://iamerrorgenerator.com/
|
||
|
|
||
|
local distId
|
||
|
|
||
|
echo "querying for CloudFront distribution..."
|
||
|
distId=$(
|
||
|
aws cloudfront list-distributions \
|
||
|
--query "DistributionList.Items[?contains(Aliases.Items, 'iamerrorgenerator.com')].Id | [0]" \
|
||
|
--output text
|
||
|
)
|
||
|
|
||
|
if [[ -z "${distId}" ]]; then
|
||
|
echo "failed to find cloudfront distribution"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "found distribution \"${distId}\", invalidating CloudFront cache..."
|
||
|
|
||
|
aws cloudfront create-invalidation \
|
||
|
--distribution-id "${distId}" \
|
||
|
--paths '/*'
|
||
|
|
||
|
echo "all done in ${SECONDS}s"
|
||
|
}
|
||
|
|
||
|
main "$@"
|