错误信息:
terraform destroy
module.application.google_sql_database_instance.sql-db-xxx: Destroying... [id=db-xxx]
Error: Error, failed to delete instance because deletion_protection is set to true. Set it to false to proceed with instance deletion
terraform 解决方案在这里:
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance
On newer versions of the provider, you must explicitly set deletion_protection=false (and run terraform >apply to write the field to state) in order to destroy an instance. It is recommended to not set this >field (or set it to true) until you're ready to destroy the instance and its databases.
题:
我不想对 terraform 脚本进行更改。我宁愿通过 gcloud 切换删除保护标志,然后照常销毁。
对于 gcloud 虚拟机,我可以切换一个删除保护标志。但是,我找不到数据库的相应标志:
cloud sql instances describe db-xxx
我没有足够的“积分”可以添加到类似标题的现有线程中。
最佳答案
回答您的问题:
deletion_protection
- Whether or not to allow Terraform to destroy the instance.
所以是的,这是在 Terraform 内部。 GCP 上的删除保护标志目前仅适用于 Compute Engine 实例,不适用于 Cloud SQL 实例。
terraform apply -var="deletion_protection=false"
terraform destroy
还有其他方法可以使用输入变量。如需更多引用,请访问 link .
关于gcloud - GCP Cloud SQL 未能删除实例,因为 `deletion_protection` 设置为 true - gcloud 切换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65097668/