4
29

How to delete S3 bucket with AWS CLI

Reading Time: < 1 minute

After creating a bucket and testing, we might want to delete the created S3 bucket with AWS CLI to clean up. There are 2 method to delete.

Before we go into the details, please ensure that you have the latest version of AWS CLI installed by referring to AWS documentation.

Deleting S3 bucket with s3

If we have a empty bucket, just run the rb command to delete the bucket.

# Delete S3 'my-bucket'
aws s3 rb s3://my-bucket

If there are things inside the bucket and can remove everything, we can add a --force option to remove everything inside also

# Create S3 'my-bucket'
aws s3 mb s3://my-bucket

Deleting S3 bucket with s3api

s3api command also have the capability to delete s3 bucket.

If you need more information, we have done a comparison between s3 and s3api command here.

aws s3api delete-bucket --bucket my-bucket --region xxxxxx

Conclusion

Deleting a bucket is simple if you decide to also delete everything that is inside the bucket. However, if you need to just delete objects, we have a guide here.

Show Comments

No Responses Yet

Leave a Reply