LoginSignup
0
0

More than 3 years have passed since last update.

複数のディレクトリ内のファイルをaws cliでs3へアップロード

Posted at

aws cli でのエラー

findで、現在のディレクトリ以下に存在するディレクトリ内のファイルをまるっとs3にあげたいなと。
そこで再帰的に

find . -type d  | aws s3 cp - s3://${S3_BUCKET} --recursive

のようにしたら Reason: exit status 255 でエラー。
ドキュメントによると、エラー内容は↓とのこと。

255: コマンドが失敗しました。リクエストが送信された AWS CLI または AWS サービスのいずれかでエラーが生成されました。
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-usage-returncodes.html

--debugオプションをつける

CodeBuildには正しい権限を付与しているはず。。。
--debugオプションで検証。

Streaming currently is only compatible with non-recursive cp commands

と怒られていました。...ですよね。

コマンドの修正

find . -type d | while read dir
do
  aws s3 cp $dir s3://$S3_BUCKET/$dir --recursive
done

./dir内のファイルはs3の/dir/以下に、./dir2内のファイルは/dir2/以下に無事アップロード完了。

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