From the course: AWS for Developers: S3

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Deleting a bucket

Deleting a bucket

- [Instructor] When you don't need a bucket, say because it was for temporary storage, you need a programmatic way to delete it. This is powerful in leveraging buckets for long running jobs and cleaning up after yourself when you're done. So let's take a look at the delete API. Jump back into our python file here, and we'll create another new method. This time calling it delete_bucket, we'll need to send it in a bucket name and our s3 resource. We will do a try on this. And we will go into the s3 bucket itself and we will call delete. And we will now except that. And print that error out. Now we will get rid of our download link. And we will first start by calling create_bucket. When we call create_bucket we use our transient name and s3. And then we will delete our bucket, using the TRANSIENT_BUCKET_NAME and s3. There's no real good way that I can think of to actually make sure that this works, so what I'm going to do…

Contents