-
-
Save olen2006/d68292f86fbedc4b25a1ff88c870809d to your computer and use it in GitHub Desktop.
Fetch AWS Cloudfront Logs, decompress, combine into a single file and remove comments
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
#!/usr/bin/env bash | |
BUCKET=$1 | |
CWD=$(pwd) | |
if [[ -n $1 ]]; then | |
aws s3 sync s3://$BUCKET/cf-logs . | |
cat *.gz > combined.log.gz | |
find $CWD ! -name 'combined.log.gz' -name '*.gz' -type f -exec rm -f {} + | |
gzip -d combined.log.gz | |
sed -i '/^#/ d' combined.log | |
exit 0 | |
else | |
echo "Error: no bucket name provided" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://shapeshed.com/aws-cloudfront-log/
The script does the following: