How to delete all files from S3 Bucket by using command line

It is not obvious how to delete all files (including sub-folders) if you read AWS CLI S3 documentation. But there is a trick by using AWS S3 sync command

  1. cd ANY_EMPTY_FOLDER_ON_YOU_COMPUTER
  2. aws s3 sync . s3://YOUR-BUCKET-NAME --delete

Be careful! This effectively will empty your AWS S3 Bucket completely. You can do the same for nested folders.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: