petoju / terraform-provider-mysql

Terraform MySQL provider – unofficial fork
https://registry.terraform.io/providers/petoju/mysql
Mozilla Public License 2.0
63 stars 40 forks source link

Feature request: add option to remove database from state instead of dropping it during delete #94

Open noxjonas opened 8 months ago

noxjonas commented 8 months ago

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.

piotrkochan commented 3 months ago

Just use Terraform state rm