Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

****************I am authoring a Book on Oracle Database Cloud Services.......More details to follow.***************

Title : Oracle Database Cloud Revealed
Publisher : Apress
Release Date : Jan-2019

**********************************************************************************


Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]


My Cloud Certifications:

AWS Certified Solutions Architect Associate

Oracle Cloud Infrastructure 2018 Certified Architect Associate.

Oracle Cloud Infrastructure Classic 2018 Certified Architect Associate.

Oracle Database Cloud Administrator Certified Professional.

Oracle Database Cloud Service Operations Certified Associate.

Search This Blog

Wednesday, October 11, 2017

aws s3 remove_bucket failed: You must delete all versions in the bucket

Currently this is a limitation in S3 but you can use external programs using python with boto or boto3 or java to delete through the versions and then delete the bucket.

else

use console to delete the versions and then delete the bucket.

Below I am boto to delete the versions and then the empty bucket.

shaiks@shaikslinux>aws s3  ls s3://
2017-10-11 15:56:55 shaiks3333
2017-10-05 18:55:57 shaiks3334
2017-10-06 03:55:40 thecloudgenie.com
2017-10-05 18:58:51 www.thecloudgenie.com


Here is error message:
shaiks@shaikslinux>aws s3  rb s3://shaiks3333/
remove_bucket failed: s3://shaiks3333/ An error occurred (BucketNotEmpty) when calling the DeleteBucket operation: The bucket you tried to delete is not empty. You must delete all versions in the bucket.


Using boto to delete the versions:
shaiks@shaikslinux>python remove_bucket3.py

shaiks@shaikslinux>cat remove_bucket3.py
import boto3

BUCKET = 'shaiks3333'

s3 = boto3.resource('s3')
bucket = s3.Bucket(BUCKET)
bucket.object_versions.delete()

# if you want to delete the now-empty bucket 
bucket.delete()

shaiks@shaikslinux>aws s3 ls s3://
2017-10-05 18:55:57 shaiks3334
2017-10-06 03:55:40 thecloudgenie.com
2017-10-05 18:58:51 www.thecloudgenie.com


Bucket shaiks3333 is now deleted from s3:


No comments: