0
0

More than 3 years have passed since last update.

[AWS][S3] S3 から pprefix 付きでファイルをコピーする

Posted at

CloudFront のログから特定の日時のものだけコピーしようとしても aws s3 sync だとディレクトリ単位でしかコピーできない。
そんな時は、以下の感じで

#! /bin/bash
S3_BUCKET_NAME='__S3_BUCKET_NAME__'
CF_DIST_ID='__CLOUDFRONT_DISTRIBUTION_ID_HERE__'

BASEURL="s3://${S3_BUCKET_NAME}/CloudFrontLogs/"
FILTER="${CF_DIST_ID}.2021-01-01

for F in $(aws s3 ls $BASEURL/$FILTER | awk '{print $4}'); do
  echo $F
  aws s3 cp $BASEURL/$F .
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0