[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-05。"],[],[],null,["# Prevent deletion of an instance\n\nThis page describes how to protect Memorystore for Valkey instances from accidental\ndeletion.\n\nOverview\n--------\n\nInstance deletion protection lets you prevent the accidental removal of\nexisting and new instances. Using instance deletion protection, you can\nsafeguard instances that are important to your applications and services.\n\nYou can set the deletion protection option when you create an instance.\nAdditionally, you can set this option on an existing instance. In both cases,\ndeletion is prevented at the instance level. By default, the deletion protection\noption is disabled unless you use Terraform to create an instance.\n\nPlanning for deletion protection\n--------------------------------\n\nIf you are planning to create an instance, decide whether you want to protect\nthe new instance from accidental deletion. For example, a critical instance\nshould be protected in this way.\n\nAlso consider whether there are existing instances you want to protect from\naccidental deletion. If you have multiple instances to protect, set the option\non each instance.\n\n### Planning for instance deletion\n\nIf you are planning to delete an instance, first do the following:\n\n- Confirm that it is safe to delete the instance\n- Confirm that deletion protection is disabled; if necessary, edit the instance to disable deletion protection\n\n### Limitations of deletion protection\n\nDeletion protection on an instance does not prevent:\n\n- Editing the instance\n- Suspending the instance due to billing issues\n- Deleting the suspended instance due to billing issues\n- Deleting the instance due to a project deletion\n\nRequired permissions\n--------------------\n\nTo set deletion protection on an instance, you must have the\n`memorystore.instances.update` permission.\n\nSetting deletion protection on a new instance\n---------------------------------------------\n\nThe following are the ways to set the deletion protection option. By default,\nthe deletion protection option is disabled unless you use Terraform to create an\ninstance.\n\nIf deletion protection is enabled, an attempt to delete the instance fails. \n\n### gcloud\n\nTo turn on deletion protection while creating an instance, follow the\ninstructions at [Create an instance](/memorystore/docs/valkey/create-instances#gcloud),\nand add the following flag: \n\n```\ngcloud memorystore instances create INSTANCE \\\n --deletion-protection-enabled \\\n --location=REGION_ID \\\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e is the ID of the your instance.\n- \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is the region where your instance is located.\n\nSetting or removing deletion protection on an existing instance\n---------------------------------------------------------------\n\nThe following are the ways to edit an instance for deletion protection. If you\nenable the option, a subsequent attempt to delete the instance fails. \n\n### gcloud\n\nTo enable deletion protection for an existing instance, use a command\nsimilar to the following: \n\n```\ngcloud memorystore instances update INSTANCE \\\n --deletion-protection-enabled \\\n --location=REGION_ID \\\n```\n\nTo disable deletion protection for an existing instance, use a command\nsimilar to the following: \n\n```\ngcloud memorystore instances update INSTANCE \\\n --no-deletion-protection-enabled \\\n --location=REGION_ID \\\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e is the ID of the your instance.\n- \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is the region where your instance is located."]]