Google Cloud SDK
cloud.gcp
Protects against destructive gcloud operations like instances delete, sql instances delete, and gsutil rm -r
- 23blocking rules
- 7safe patterns
- 16Critical
- 7High
[packs]
enabled = ["cloud.gcp"]Evaluated when a command contains gcloud, gsutil, delete, instances, artifacts, images, repositories, bq, secrets, kms.
Blocking rules
Each rule ID is cloud.gcp:<name>. Use it in allowlists and [policy.rules].
Criticalartifacts-repositories-deletegcloud artifacts repositories delete permanently deletes the repository.
Explanation
artifacts repositories delete removes entire repository: - All packages/images in repository deleted - Repository configuration lost - IAM policies on repository removed List contents: gcloud artifacts packages list --repository=REPO
Criticalbigtable-instances-deletegcloud bigtable instances delete destroys a Bigtable instance — all tables and data lost.
Explanation
bigtable instances delete removes a Bigtable instance: - All tables, clusters, and data are permanently deleted - No backup unless one was explicitly taken - Downstream pipelines consuming from Bigtable fail Take a backup first: cbt -instance=INST createsnapshot CLUSTER TABLE SNAPSHOT 30
Criticalbq-rm-recursivebq rm -r/-f removes BigQuery datasets, tables, or models — data lost.
Explanation
bq rm recursively deletes BigQuery resources: - `bq rm -r DATASET`: removes dataset + ALL tables/views/models inside - `bq rm -f TABLE`: removes a table without confirmation - Data is not recoverable (unless a prior `EXPORT` or snapshot exists) - No trash/recycle bin Export first: bq extract --destination_format=NEWLINE_DELIMITED_JSON \ DATASET.TABLE gs://bkt/backup/*.json
Criticalcompute-deletegcloud compute instances delete permanently destroys VM instances.
Explanation
compute instances delete permanently destroys VMs: - Instance is stopped and deleted - Boot disk deleted (unless --keep-disks specified) - External IPs released back to pool - Instance metadata and logs lost Use --keep-disks=boot,data to preserve disks for recovery.
Criticaldisk-deletegcloud compute disks delete permanently destroys disk data.
Explanation
compute disks delete permanently destroys persistent disks: - All data on the disk is lost forever - Cannot be recovered without snapshots - Any instances using the disk will fail Create a snapshot before deletion: gcloud compute disks snapshot DISK
Criticaldns-managed-zones-deletegcloud dns managed-zones delete removes a DNS zone — domains stop resolving.
Explanation
dns managed-zones delete removes a Cloud DNS zone: - All record sets in the zone are deleted - Domains configured with this zone's nameservers stop resolving immediately - Production traffic can go dark - No undelete Export records first: gcloud dns record-sets export zone-backup.yaml --zone=ZONE
Criticalfirestore-deletegcloud firestore delete removes Firestore data.
Explanation
firestore delete removes Firestore documents: - Documents and collections deleted - Subcollections may remain (delete recursively) - No automatic backups by default Export first: gcloud firestore export gs://bucket/backup
Criticalgke-deletegcloud container clusters delete removes the entire GKE cluster.
Explanation
container clusters delete removes the entire GKE cluster: - All nodes and workloads terminated - Persistent volumes may be deleted - Load balancers and IPs released - Cluster-level secrets lost Backup workloads: kubectl get all -A -o yaml > backup.yaml
Criticalgsutil-rbgsutil rb removes the entire GCS bucket.
Explanation
gsutil rb removes the entire Cloud Storage bucket: - Bucket must be empty (or use -f to force) - Bucket name becomes available to others - All bucket-level permissions lost List contents first: gsutil ls gs://bucket/
Criticalgsutil-rm-recursivegsutil rm -r permanently deletes all objects in the path.
Explanation
gsutil rm -r recursively deletes all objects: - All objects under the path are deleted - Cannot be recovered without versioning enabled - -m flag parallelizes (faster but same risk) List first: gsutil ls -r gs://bucket/path/ Enable versioning: gsutil versioning set on gs://bucket
Criticaliam-service-accounts-deletegcloud iam service-accounts delete removes a service account — workloads authenticating with it break.
Explanation
iam service-accounts delete removes a service account: - Every workload using this SA loses access - Keys associated with the SA are deleted - CI/CD pipelines, GKE workloads, Cloud Functions dependent on this SA fail - Can undelete within 30 days via `gcloud iam service-accounts undelete` List usages first: gcloud iam service-accounts get-iam-policy SA-EMAIL
Criticalkms-keys-destroygcloud kms keys versions destroy schedules a CryptoKeyVersion for destruction — data encrypted with it becomes unrecoverable.
Explanation
kms keys versions destroy scheduled destruction of a key version: - 24-hour waiting period by default (per-keyring policy) - After destruction: ALL data encrypted under this version is unrecoverable - `gcloud kms keys versions restore` can undo within the waiting window Consider `disable` instead if reversibility matters: gcloud kms keys versions disable VERSION --key=KEY --keyring=RING --location=LOC
Criticalproject-deletegcloud projects delete removes the entire GCP project and ALL its resources!
Explanation
projects delete removes the ENTIRE GCP project: - ALL resources in the project deleted - All VMs, databases, storage, functions - All IAM policies and service accounts - 30-day recovery window, then permanent This is the most destructive GCP command possible!
Criticalsecrets-deletegcloud secrets delete destroys a Secret Manager secret — credentials gone.
Explanation
secrets delete removes a Secret Manager secret: - Secret and ALL its versions are permanently deleted - No recovery window (unlike AWS Secrets Manager) - Applications using the secret will fail to authenticate List versions first: gcloud secrets versions list SECRET Disable rather than delete: gcloud secrets versions disable VERSION --secret=SECRET
Criticalspanner-instances-deletegcloud spanner instances delete destroys a Spanner instance — all databases and data lost.
Explanation
spanner instances delete removes a Spanner instance: - All databases inside the instance are deleted - Data is unrecoverable unless previously exported - Applications writing to these DBs fail immediately Export data first: gcloud dataflow jobs run export-spanner --region=REGION \ --parameters=sourceInstance=INST,destinationPath=gs://bkt/backup/
Criticalsql-deletegcloud sql instances delete permanently destroys the Cloud SQL instance.
Explanation
sql instances delete permanently destroys Cloud SQL: - Database and all data deleted - All backups deleted (unless retained) - Read replicas also deleted - IP addresses released Export data first: gcloud sql export sql INSTANCE gs://bucket/file.sql
Highartifacts-docker-images-deletegcloud artifacts docker images delete permanently deletes container images.
Explanation
artifacts docker images delete removes images from Artifact Registry: - Specified image version deleted - Other tags pointing to same digest unaffected - Consider cleanup policies instead List versions: gcloud artifacts docker images list REPO
Highcontainer-images-deletegcloud container images delete permanently deletes container images.
Explanation
container images delete removes images from GCR: - Image tags and digests deleted - Running containers unaffected (cached) - New pulls will fail List tags first: gcloud container images list-tags IMAGE
Highdataproc-clusters-deletegcloud dataproc clusters delete destroys a Dataproc (Hadoop/Spark) cluster.
Explanation
dataproc clusters delete removes a Dataproc cluster: - Running jobs are killed - Any data stored on local HDFS or cluster-local disks is lost - Data in GCS (external) is preserved - Cluster name is reserved for ~5 min; re-creation may fail until it clears
Highfunctions-deletegcloud functions delete removes the Cloud Function.
Explanation
functions delete removes Cloud Functions: - Function code and configuration deleted - Triggers and event subscriptions removed - Function URL becomes unavailable Export source first if not in version control.
Highiam-roles-deletegcloud iam roles delete removes a custom IAM role — all users/SAs bound to it lose the permissions.
Explanation
iam roles delete removes a custom IAM role: - Every user/group/SA bound to this role loses its permissions - Predefined roles cannot be deleted; this always targets custom roles - Role is soft-deleted for 7 days, then permanently removed Audit bindings first via gcloud projects get-iam-policy PROJECT
Highlogging-sinks-deletegcloud logging sinks delete removes an audit-log export — compliance/forensics impact.
Explanation
logging sinks delete stops log export to BigQuery/PubSub/Storage: - Historical exports remain at the destination - Future events stop flowing to the configured sink - Compliance regimes (SOC2, ISO 27001) may require this sink Consider disabling by updating filter: gcloud logging sinks update SINK --log-filter='false'
Highpubsub-deletegcloud pubsub delete removes Pub/Sub topics or subscriptions.
Explanation
pubsub delete removes messaging infrastructure: - Topic deletion removes all subscriptions - Unacknowledged messages are lost - Publishers will fail until recreated Check subscribers: gcloud pubsub topics list-subscriptions TOPIC
Safe patterns
Checked first. A command that matches one is never blocked by this pack.
gcloud-describegcloud-listgsutil-lsgsutil-cpgcloud-configgcloud-authgcloud-info