Last active
November 23, 2022 17:09
-
-
Save sasasin/5e11c40fbc947156fe5f983f8eb36dcd to your computer and use it in GitHub Desktop.
CloudFront アクセスログや S3 アクセスログを Athena パーティショニングが使えるようリネームするやつ
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 -e | |
| set -o pipefail | |
| # how to use | |
| # rename-to-s3-access-log-for-athena-partitioning.sh "s3://hogehoge/piyopiyo" "2022" "11" "23" | |
| S3_ACCESS_LOG_BUCKET_PATH="$1" | |
| YYYY="$2" | |
| MM="$3" | |
| DD="$4" | |
| s5cmd mv \ | |
| "${S3_ACCESS_LOG_BUCKET_PATH}/${YYYY}-${MM}-${DD}-*-*-*-*" \ | |
| "${S3_ACCESS_LOG_BUCKET_PATH}/${YYYY}/${MM}/${DD}/" |
ALB などと同様の階層構造に置くようにして、Athenaの Partition Projection 定義を使いまわせるようにした
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aws s3 mv をチマチマやってたら遅すぎたので s5cmd mv に改めた