Prevent deletion of a cluster

Cluster deletion protection lets you prevent the accidental removal of existing and new clusters. Using cluster deletion protection, you can safeguard clusters that are important to your applications and services.

You can set the deletion protection option when you create a cluster. Additionally, you can set this option on an existing cluster. In both cases, deletion is prevented at the cluster level. By default, the deletion protection option is deactivated unless you use Terraform to create a cluster.

Plan for deletion protection

If you plan to create a cluster, then decide whether you want to protect the cluster from accidental deletion. For example, you might want to protect a critical cluster in this way.

Also consider whether there are existing clusters that you want to protect from accidental deletion. If you have multiple clusters to protect, then set the option on each cluster.

Plan to delete a cluster

If you plan to delete a cluster, then do the following:

  • Confirm that it's safe to delete the cluster.
  • Confirm that deletion protection is deactivated.
  • If necessary, edit the cluster to deactivate deletion protection.

Limitations of deletion protection

Deletion protection on a cluster doesn't prevent the following actions from occurring:

  • Editing the cluster
  • Suspending the cluster because of billing issues
  • Deleting the suspended cluster because of billing issues
  • Deleting the cluster because a Google Cloud project is deleted

Required permissions

To set deletion protection on a cluster, you must have the redis.instances.update permission.

Set deletion protection on a new cluster

You can set deletion protection on a new cluster by using the gcloud CLI.

By default, deletion protection is deactivated unless you use Terraform to create a cluster. If you enable deletion protection, then an attempt to delete the cluster fails.

gcloud

To enable deletion protection while creating a cluster, follow the instructions at Create instances, and add the following flag:

gcloud redis clusters create CLUSTER_ID \
--region=REGION_ID \
--deletion-protection

Make the following replacements:

  • CLUSTER_ID: the ID of the cluster that you want to protect from being deleted
  • REGION_ID: the region where the cluster is located

Set or remove deletion protection on an existing cluster

You can set or remove deletion protection on an existing cluster by using the gcloud CLI. If you enable deletion protection, then a subsequent attempt to delete the cluster fails.

gcloud

To enable deletion protection for an existing cluster, use the following command:

gcloud redis clusters update CLUSTER_ID \
--region=REGION_ID \
--deletion-protection

Make the following replacements:

  • CLUSTER_ID: the ID of the cluster that you want to protect from being deleted
  • REGION_ID: the region where the cluster is located

To deactivate deletion protection for an existing cluster, use the following command:

gcloud redis clusters update CLUSTER_ID \
--region=REGION_ID \
--no-deletion-protection