You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
At the moment, the only way to prevent terraform from destroying a database is to use the prevent destroy lifecycle. This has limitations because variables cannot be used inside the lifecycle block.
A solution would be to include an argument that controls whether Terraform can destroy the database.
Google implementation example: deletion_protection - (Optional) Whether Terraform will be prevented from destroying the instance. When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the instance will fail. When the field is set to false, deleting the instance is allowed.
Community Note
Description
At the moment, the only way to prevent terraform from destroying a database is to use the prevent destroy lifecycle. This has limitations because variables cannot be used inside the lifecycle block.
A solution would be to include an argument that controls whether Terraform can destroy the database.
New or Affected Resource(s)
Potential Terraform Configuration
References
Google implementation example:
deletion_protection - (Optional) Whether Terraform will be prevented from destroying the instance. When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the instance will fail. When the field is set to false, deleting the instance is allowed.
https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/version_5_upgrade#cluster-deletion-now-prevented-by-default-with-deletion_protection
AWS implementation example:
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#deletion_protection
The text was updated successfully, but these errors were encountered: