[AWS] How to delete every objects in S3 bucket

Purpose
In this article, let me explain how to delete every objects in S3 bucket.
Before deleting S3 bucket, you need to delete every objects in the bucket.
But if you have many objects in the S3 bucket, it will take time to delete them by the management console.
In this case, CLI deletion is very effective to save your time.
How to delete every objects in S3 bucket
In my bucket, there are many objects over 999. It will take so much time to delete it by this console. So, let’s start cloud shell by clicking red square icon.

By executing “aws s3 rm” command, you can delete objects by applying regular expression.
Before I actually execute this command, I applied dryrun option. You can check delete target  objects in advance.


Check if delete target objects are correct.

If it is OK, let’s execute “aws s3 rm” command without dryrun option.


OK, the command is completed without any errors.
Let’s check the existence of objects in the management console just to be safe.


OK, every objects are deleted completely !!

That’s all for this topic. If you think this article is beneficial for you, I would be glad if you click below icon for my motivation.
ブログランキング・にほんブログ村へ

コメント