Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deletion_protection argument to database resource #5534

Open
andrei-pirciu opened this issue Jul 29, 2024 · 1 comment · May be fixed by #5626
Open

Add deletion_protection argument to database resource #5534

andrei-pirciu opened this issue Jul 29, 2024 · 1 comment · May be fixed by #5626
Labels
enhancement service/Cloud Databases Issues related to Cloud Databases

Comments

@andrei-pirciu
Copy link

andrei-pirciu commented Jul 29, 2024

Community Note

  • 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.

New or Affected Resource(s)

  • ibm_database

Potential Terraform Configuration

resource "ibm_database" "test_acc" {
  resource_group_id                    = data.ibm_resource_group.group.id
  name                                 = "<your_database_name>"
  service                              = "databases-for-postgresql"
  plan                                 = "standard"
  location                             = "eu-gb"

  deletion_protection = var.enable_deletion_protection  # <----
}

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

  • #0000
@github-actions github-actions bot added the service/Cloud Databases Issues related to Cloud Databases label Jul 29, 2024
@dpittner dpittner linked a pull request Sep 8, 2024 that will close this issue
@dpittner
Copy link
Contributor

@andrei-pirciu can you take a look at the PR I proposed and comment on if it would address the scenario you have in mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement service/Cloud Databases Issues related to Cloud Databases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants