Prevent deletion of an instance

This page describes how to protect Memorystore for Redis Cluster instances from accidental deletion.

Overview

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

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

Planning for deletion protection

If you are planning to create an instance, decide whether you want to protect the new instance from accidental deletion. For example, a critical instance should be protected in this way.

Also consider whether there are existing instances you want to protect from accidental deletion. If you have multiple instances to protect, set the option on each instance.

Planning for instance deletion

If you are planning to delete an instance, first do the following:

  • Confirm that it is safe to delete the instance
  • Confirm that deletion protection is disabled; if necessary, edit the instance to disable deletion protection

Limitations of deletion protection

Deletion protection on an instance does not prevent:

  • Editing the instance
  • Suspending the instance due to billing issues
  • Deleting the suspended instance due to billing issues
  • Deleting the instance due to a project deletion

Required permissions

To set deletion protection on an instance, you must have the redis.instances.update permission.

Setting deletion protection on a new instance

The following are the ways to set the deletion protection option. By default, the deletion protection option is disabled unless you use Terraform to create an instance.

If deletion protection is enabled, an attempt to delete the instance fails.

gcloud

To turn on deletion protection while creating an instance, follow the instructions at Create an instance, and add the following flag:

gcloud redis clusters create INSTANCE_ID \
  --deletion-protection

Setting or removing deletion protection on an existing instance

The following are the ways to edit an instance for deletion protection. If you enable the option, a subsequent attempt to delete the instance fails.

gcloud

To enable deletion protection for an existing instance, use a command similar to the following:

gcloud redis clusters update INSTANCE_ID \
  --deletion-protection

To disable deletion protection for an existing instance, use a command similar to the following:

gcloud redis clusters update INSTANCE_ID \
  --no-deletion-protection