How can I tell how many objects I've stored in an S3 bucket?

后端 未结 29 3708
逝去的感伤
逝去的感伤 2020-12-02 04:45

Unless I\'m missing something, it seems that none of the APIs I\'ve looked at will tell you how many objects are in an /. Is ther

29条回答
  •  庸人自扰
    2020-12-02 05:24

    Using AWS CLI

    aws s3 ls s3://mybucket/ --recursive | wc -l 
    

    or

    aws cloudwatch get-metric-statistics \
      --namespace AWS/S3 --metric-name NumberOfObjects \
      --dimensions Name=BucketName,Value=BUCKETNAME \
                  Name=StorageType,Value=AllStorageTypes \
      --start-time 2016-11-05T00:00 --end-time 2016-11-05T00:10 \
      --period 60 --statistic Average
    

    Note: The above cloudwatch command seems to work for some while not for others. Discussed here: https://forums.aws.amazon.com/thread.jspa?threadID=217050

    Using AWS Web Console

    You can look at cloudwatch's metric section to get approx number of objects stored.

    I have approx 50 Million products and it took more than an hour to count using aws s3 ls

提交回复
热议问题