1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

S3バケットの特定のプレフィックス配下の容量を取得したい場面がありまして、AWS CLIで一発で取得できたので、備忘録として記事にしておきたいと思います。

やり方

以下のCLIコマンドを打つだけです!

aws s3 ls s3://バケット名/プレフィックス/ --recursive --human-readable --summarize

CloudShellで簡単に実行できます。
実行すると、指定したプレフィックス配下のオブジェクト一覧が表示され、最後に以下のような出力がされます。

Total Objects: 687
   Total Size: 640.0 MiB

ちなみに各オプションは以下の役割です。

  • --recursive: サブディレクトリも含めて再帰的に検索
  • --human-readable: 容量を人が読みやすい形式で表示(MB、GBなど)
  • --summarize: 合計ファイル数と合計容量を表示

最後に

たまにこういった場面があるので備忘として取っておきました。
また、Lambda + EventBridgeを使用することでカスタムメトリクスとして登録するのもよさそうです!

弊社では一緒に働く仲間を募集中です!

現在、様々な職種を募集しております。
カジュアル面談も可能ですので、ご連絡お待ちしております!

募集内容等詳細は、是非採用サイトをご確認ください。
https://engineer.po-holdings.co.jp/

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?