Prevent deletion of an instance Stay organized with collections Save and categorize content based on your preferences.
This page describes how to protect Memorystore for Valkey instances from accidentaldeletion.
Overview
Instance deletion protection lets you prevent the accidental removal ofexisting and new instances. Using instance deletion protection, you cansafeguard 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 protectionoption is disabled unless you use Terraform to create an instance.
Plan for deletion protection
If you are planning to create an instance, decide whether you want to protectthe new instance from accidental deletion. For example, a critical instanceshould be protected in this way.
Also consider whether there are existing instances you want to protect fromaccidental deletion. If you have multiple instances to protect, set the optionon each instance.
Plan to delete an instance
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 theinstance 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 thememorystore.instances.update permission.
Set 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 aninstance.
If deletion protection is enabled, an attempt to delete the instance fails.
gcloud
To turn on deletion protection while creating an instance, follow theinstructions atCreate a multi-zone instanceand add the following flag:
gcloud memorystore instances createINSTANCE \ --deletion-protection-enabled \ --location=REGION_ID \
Replace the following:
- INSTANCE is the ID of your instance.
- REGION_ID is the region where your instance is located.
Set or remove deletion protection on an existing instance
The following are the ways to edit an instance for deletion protection. If youenable the option, a subsequent attempt to delete the instance fails.
gcloud
To enable deletion protection for an existing instance, use a commandsimilar to the following:
gcloud memorystore instances updateINSTANCE \ --deletion-protection-enabled \ --location=REGION_ID \
To disable deletion protection for an existing instance, use a commandsimilar to the following:
gcloud memorystore instances updateINSTANCE \ --no-deletion-protection-enabled \ --location=REGION_ID \
Replace the following:
- INSTANCE is the ID of the your instance.
- REGION_ID is the region where your instance is located.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.