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

Feature request: being able to change behaviour when changing host / username for a mysql_user resource #185

Open
ezerfernandes opened this issue Dec 9, 2024 · 1 comment

Comments

@ezerfernandes
Copy link

ezerfernandes commented Dec 9, 2024

Provider version

Terraform v1.6.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v5.80.0
+ provider registry.terraform.io/petoju/mysql v3.0.65

MySQL version and settings

mysql  Ver 8.0.40-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

Terraform Configuration Files

resource "mysql_user" "svc_user" {
    user = "svc_user"
    host = "%"
}

It was changed to

resource "mysql_user" "svc_user" {
    user = "svc_user"
    host = "10.%"
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

To have the option of defining that terraform apply on this change would execute

RENAME USER 'svc_user'@'%' TO 'svc_user'@'10.%';

Instead of removing the user and creating a new user. In this way, the password of the MySQL user being used as service user by a production app wouldn't have to be updated and the service wouldn't have to be interrupted.

Actual Behavior

Changing host destroys the DB user and creates a new DB user.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

I think the should be an option at the provider level that, by default, keeps the current behaviour, but that can be changed in case that's what's wanted.

References

N/A

@petoju
Copy link
Owner

petoju commented Dec 9, 2024

Your suggestion makes sense and I don't think there has to be a provider-level setting to preserve the old behavior.
If someone wants to do destroy & create, they can rename the resource.

However, I don't have a lot of time to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants