Skip to content

Instantly share code, notes, and snippets.

@jsmcnair
Last active October 18, 2024 06:52
Show Gist options
  • Save jsmcnair/d0cada209350bc528606ac32d64587cd to your computer and use it in GitHub Desktop.
Save jsmcnair/d0cada209350bc528606ac32d64587cd to your computer and use it in GitHub Desktop.
Useful gcloud commands
PROJECT="<project_name>"
REGION="<region_name>"
# Delete all filestore backups in $PROJECT $REGION using gcloud CLI
gcloud filestore backups list --project $PROJECT --region $REGION --format "value(name)" |
xargs -d "\n" -I '{}' gcloud filestore backups delete '{}' --region $REGION --quiet --async --project $PROJECT
# Delete all disk snapshots in $PROJECT
gcloud compute snapshots list --project $PROJECT --format "value(name)" |
xargs gcloud compute snapshots delete --project $PROJECT
# Delete all secrets in $PROJECT
gcloud secrets list --project $PROJECT --format "value(name)" |
xargs -d '\n' -I '{}' gcloud secrets delete '{}' --quiet --project $PROJECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment