petoju / terraform-provider-mysql

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

Error with 2 succcessive apply #18

Closed ddup1 closed 2 years ago

ddup1 commented 2 years ago

Hi,

After i saw that mysql provider is no more maintained by Hashicorps, i search for an alternative and begin update to tf1.1 or 1.2

I found your mysql provider that is a fork from the original provider.

The first time i launch terraform apply, my db user are well created, but if i launch a terraform apply a second time, then i got an error :

Error: Create user couldn't be parsed - it is CREATE USER myuser@% IDENTIFIED BY PASSWORD '*ABDEFGHIJKLMNOPR'

Any idea about this issue ?

I use terraform 1.1.9 and mysql provider 3.0.17.

Regards.

ddup1 commented 2 years ago

I just check the code with the error i get and saw the regexp that is used to test if user already exist :
^CREATE USER '`[']@[']([^']*)['] IDENTIFIED WITH '`['`] (?:AS '((?:.?[^\\])?)' )?REQUIRE ([^ ])")

I use mariadb and when i do show create user toto, i get this : CREATE USER toto@% IDENTIFIED BY PASSWORD '*ABCDEFGHIJKLMNOPQRSTUVWXYZ'

It don't know what mysql return but i think the regexp must check both.

petoju commented 2 years ago

@ddup1 you are right - it is an issue, because we currently test only Percona and MySQL. Would you mind sending a patch to run tests on MariaDB and adding another regex?

I can get to this only later.

For now, you can enforce provider version 3.0.12, that didn't have such issue. That said, it was not able to read some user settings, so one could have a config drift.

ddup1 commented 2 years ago

Hi,

Yes i was looking for it, i do some hello world in go to propose a patch for mariadb.

petoju commented 2 years ago

@ddup1 this is fixed in 3.0.18.

ddup1 commented 2 years ago

Hi,

thanks @petoju , will try this.

On my side i try to unify regexp for maria and mysql in one regexp but fail as it change the group count.

Thanks a lot.