Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit

Permalink
Cleanup buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddelkoop committed Dec 13, 2021
1 parent 411a32c commit dd8edbd
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/GCP/06_running_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 4,
"id": "f36cb8c5-f305-4cb2-a5cc-0c9fd8592fb4",
"metadata": {},
"outputs": [
Expand Down
126 changes: 126 additions & 0 deletions content/GCP/08_cleaning_up_resources.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,132 @@
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "d43bd86d-acf7-416a-9b35-506f5625f2c3",
"metadata": {},
"source": [
"## Cleanup Buckets\n",
"\n",
"This Episode is used to cleanup resources created by the Lesson. Note, this will clean buckets created on any day.\n",
"\n",
"First set the environment variables and verify them. If they are previously set you can just verify them."
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "86c5804d-b8ae-49d8-b67c-61360a922590",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Account: 1002111293252-compute@developer.gserviceaccount.com, Project: just-armor-301114, Region: us-west2\n",
"Bucket: essentials-learner-*\n"
]
}
],
"source": [
"ACCOUNT=$(gcloud config list --format='value(core.account)')\n",
"PROJECT=$(gcloud config list --format='value(core.project)')\n",
"BUCKET=\"essentials-${USER}-*\"\n",
"REGION=\"us-west2\"\n",
"echo \"Account: $ACCOUNT, Project: $PROJECT, Region: $REGION\"\n",
"echo \"Bucket: $BUCKET\""
]
},
{
"cell_type": "markdown",
"id": "218cc720-bf36-49a4-b98a-11024f5b391c",
"metadata": {},
"source": [
"List the buckets we will be deleting."
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "93add660-5bdb-4393-a05a-031ec301d7f8",
"metadata": {},
"outputs": [],
"source": [
"gsutil ls -b \"gs://$BUCKET\""
]
},
{
"cell_type": "markdown",
"id": "8daa2ec9-d64d-4586-8ab9-33f03c1b1138",
"metadata": {},
"source": [
"**WARNING: All of the above buckets will be deleted if the following commands are run**"
]
},
{
"cell_type": "markdown",
"id": "be020ee5-d3af-4ada-a674-51775648f373",
"metadata": {},
"source": [
"**Delete** all the objects first"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "24616c20-ae7e-4d0f-9f9c-6c8752891fa7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CommandException: 1 files/objects could not be removed.\n"
]
},
{
"ename": "",
"evalue": "1",
"output_type": "error",
"traceback": []
}
],
"source": [
"gsutil -m rm \"gs://$BUCKET/*\""
]
},
{
"cell_type": "markdown",
"id": "194c0181-6a47-43c5-af40-29230d858164",
"metadata": {},
"source": [
"Delete the empty buckets"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "a1310b76-6212-48fa-b023-0a15e06d4332",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CommandException: No URLs matched: ['gs://essentials-learner-*/']\n"
]
},
{
"ename": "",
"evalue": "1",
"output_type": "error",
"traceback": []
}
],
"source": [
"gsutil rb \"gs://$BUCKET/\""
]
}
],
"metadata": {
Expand Down

0 comments on commit dd8edbd

Please sign in to comment.