Amazon web services 获取存储桶中AWS S3密钥计数的快速方法

Amazon web services 获取存储桶中AWS S3密钥计数的快速方法,amazon-web-services,amazon-s3,s3cmd,Amazon Web Services,Amazon S3,S3cmd,有没有人知道在S3中快速计算我的钥匙数的方法 我通常使用s3cmd ls s3://bucket/| wc-l,但是我的bucket包含大量的键,这使得此操作无法完成。尝试使用aws s3 api计算bucket对象的数量- aws s3api list-objects-v2 --bucket $bucketNameToUse --query '[length(Contents[?LastModified].{Key: Key})]' --output text 完成。这是一个非常老的问题,但

有没有人知道在S3中快速计算我的钥匙数的方法


我通常使用s3cmd ls s3://bucket/| wc-l,但是我的bucket包含大量的键,这使得此操作无法完成。

尝试使用aws s3 api计算bucket对象的数量-

aws s3api list-objects-v2 --bucket $bucketNameToUse --query '[length(Contents[?LastModified].{Key: Key})]' --output text

完成。

这是一个非常老的问题,但我想我应该加上0.02美元

aws s3api list-objects-v2 --bucket $YOUR_BUCKET --no-cli-pager --query "Contents[].Key" --output text | wc -w

这将给你一个非常接近的计数,对我来说效果更好,Vipin的答案

我认为列表桶是唯一的方法。他们没有保留任何内部统计信息吗??他们应该……也许使用情况报告提供了这一点。