This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mysql_grant: Fix the read of grant option.
If multiple `mysql_grant` are defined for the same user, the grant value of the last one will be set for all of them. The example (that I used in the acceptance tests) to reproduce this bug: ```hcl terraform { required_providers { mysql = { source = "winebarrel/mysql" } } } resource "mysql_database" "db1" { name = "db1" } resource "mysql_database" "db2" { name = "db2" } resource "mysql_user" "test" { user = "test" host = "%" } resource "mysql_grant" "test_db1" { user = mysql_user.test.user host = mysql_user.test.host database = mysql_database.db1.name privileges = ["SELECT"] } resource "mysql_grant" "test_db2" { user = mysql_user.test.user host = mysql_user.test.host database = mysql_database.db2.name privileges = ["SELECT"] grant = true } ``` After the first apply of these resources, there will be a dirty plan: ```bash ●examples❯ terraform apply -auto-approve [...] mysql_database.db2: Creating... mysql_user.test: Creating... mysql_database.db1: Creating... mysql_user.test: Creation complete after 0s [id=test@%] mysql_database.db1: Creation complete after 0s [id=db1] mysql_database.db2: Creation complete after 0s [id=db2] mysql_grant.test_db1: Creating... mysql_grant.test_db2: Creating... mysql_grant.test_db2: Creation complete after 0s [id=test@%:`db2`] mysql_grant.test_db1: Creation complete after 0s [id=test@%:`db1`] Apply complete! Resources: 5 added, 0 changed, 0 destroyed. ●examples❯ terraform plan mysql_user.test: Refreshing state... [id=test@%] mysql_database.db1: Refreshing state... [id=db1] mysql_database.db2: Refreshing state... [id=db2] mysql_grant.test_db2: Refreshing state... [id=test@%:`db2`] mysql_grant.test_db1: Refreshing state... [id=test@%:`db1`] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: -/+ destroy and then create replacement Terraform will perform the following actions: # mysql_grant.test_db1 must be replaced -/+ resource "mysql_grant" "test_db1" { ~ grant = true -> false # forces replacement ~ id = "test@%:`db1`" -> (known after apply) # (6 unchanged attributes hidden) } Plan: 1 to add, 0 to change, 1 to destroy. ```
- Loading branch information