terraform-provider-mysql
terraform-provider-mysql copied to clipboard
Feature request: add option to remove database from state instead of dropping it during delete
This is a feature request.
Since in terraform it's impossible to set the prevent_destroy lifecycle hook using variables (see https://github.com/hashicorp/terraform/issues/22544) it would be nice if this could be handled by the provider.
My use case is that in dev environments, I want this provider to create/destroy databases without any issues and blockers. However, if I create/import a production database, it would be nice to mitigate potential danger of outright destroying a database. Since the type of environment is set via variables, setting the prevent_destroy lifecycle hook in code would cause problems in dev.
One implementation that would work is a remove_from_state_instead_of_delete
bool input or something, which would do as it says: remove the database from state, but do not actually drop the database.
One workaround currently is to use a user without the grant to drop databases to manage resources in prod.
Just use Terraform state rm