-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add utility to clean out resources created by tests
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This is a helper utility to remove cloud resources created by running tests. | ||
# Azure containers are not cleaned up as they can (and should) be set to auto-delete after a week. | ||
|
||
if __name__ == "__main__": | ||
import boto3 | ||
from google.cloud import storage | ||
|
||
client = boto3.client("s3") | ||
s3 = boto3.resource("s3") | ||
|
||
buckets = client.list_buckets() | ||
|
||
for bucket in buckets["Buckets"]: | ||
s3_bucket = s3.Bucket(bucket["Name"]) | ||
s3_bucket.objects.all().delete() | ||
s3_bucket.object_versions.delete() | ||
s3_bucket.delete() | ||
print(f"Deleted s3 bucket {bucket['Name']}") | ||
|
||
storage_client = storage.Client() | ||
buckets = storage_client.list_buckets() | ||
for bucket in buckets: | ||
bucket.delete(force=True) | ||
print(f"Deleted gcp bucket {bucket.name}") | ||
|
||
print(f"Not deleting Azure containers") |