Loading...

Delete files on S3 bucket with AWS cli

Used:   aws-cli 2.28  python 3.8.8 

The AWS cli lets you operate you on your AWS resources.

For S3 if you don’t do a rsync old files remain on the bucket.

Especially I have noticed that, after a content migration.

To check your content in your S3 bucket use ls for list.

aws s3 ls <bucket-name>

Example

tan@omega:~/docs$ aws s3 ls s3://myblog/
                           PRE .well-known/
                           PRE 2011/
                           PRE 2013/
                           PRE 2015/
                           PRE 2016/
                           PRE 2017/
                           PRE 2018/
                           PRE 2019/
                           PRE 2020/
                           PRE 2021/
                           PRE 2022/
                           PRE 401/
                           PRE 403/
                           PRE 404/
                           PRE 500/
                           PRE 503/
2021-12-16 00:44:45       1138 Dockerfile                           

To delete S3 objects with cli simply use rm for remove.

tan@omega:~/docs$ aws s3 rm s3://myblog/Dockerfile
delete: s3://myblog/Dockerfile
aws
Please remember the terms for blog comments.