Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete-bucket command #50

Open
simonw opened this issue Jan 17, 2022 · 2 comments
Open

delete-bucket command #50

simonw opened this issue Jan 17, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Jan 17, 2022

I already have delete-user - this would be a similar utility but for deleting buckets. Mainly so I don't have to remember how to do it with awscli.

@simonw simonw added the enhancement New feature or request label Jan 17, 2022
@simonw
Copy link
Owner Author

simonw commented Jan 17, 2022

A already wrote some code for doing this in a test here:

# Delete any buckets beginning s3-credentials-tests.
buckets = json.loads(get_output("list-buckets", "--array"))
buckets_to_delete = [
bucket["Name"]
for bucket in buckets
if bucket["Name"].startswith("s3-credentials-tests.")
]
for bucket in buckets_to_delete:
print("Deleting bucket: {}".format(bucket))
# Delete all objects in the bucket
boto3.resource("s3").Bucket(bucket).objects.all().delete()
# Delete the bucket
s3.delete_bucket(Bucket=bucket)

@mileswwatkins
Copy link

mileswwatkins commented May 24, 2022

This addition to the CLI would be much appreciated, whether as a new subcommand or alternatively as part of the delete-user subcommand (as a --delete-bucket flag, paralleling the s3-credentials create BUCKET_NAME --create-bucket pattern). Thanks for developing s3-credentials!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants