hashicorp / terraform-provider-mysql

Terraform MySQL provider – This Terraform provider is archived per our provider archiving process: https://terraform.io/docs/internals/archiving.html
https://www.terraform.io/docs/providers/mysql/
Mozilla Public License 2.0
61 stars 189 forks source link

mysql provider can't create user in AWS RDS #3

Closed hashibot closed 6 years ago

hashibot commented 7 years ago

This issue was originally opened by @kshcherban as hashicorp/terraform#10899. It was migrated here as part of the provider split. The original body of the issue is below.


Descripion

mysql provider fails to create users in AWS MySQL RDS 5.7 Connectivity between RDS and local machine is fine, I can connect using mysql client. Seems like bug in terraform's mysql code.

Logs from RDS

2016-12-22T10:03:57.309811Z 15983 [Note] Aborted connection 15983 to db: 'unconnected' user: 'root' host: '10.1.16.47' (Got an error reading communication packets)

Steps to Reproduce

Terraform Version

Terraform v0.8.1

Affected Resource

Terraform Configuration Files

provider "mysql" {
    endpoint = "${aws_db_instance.default.endpoint}"
    username = "root"
    password = "secret"
}
resource "mysql_user" "test_user" {
    user = "test"
    host = "%"
    password = "secret"
}

Debug Output

Error applying plan:

1 error(s) occurred:

* mysql_user.test: Received hashicorp/terraform#1396 error from MySQL server: "Operation CREATE USER failed for 'test'@'%'"

Nothing different in debug log.

Expected Behavior

User should be created

Actual Behavior

User was not created

leftathome commented 7 years ago

Anyone likely to pick up and research/attempt to reproduce this issue is likely to run into #2 as well. If the aws_db_instance resource referenced in the MySQL provider doesn't already exist in the Terraform state when the MySQL provider is configured, the run is likely to fail. (At least, it did for me in 0.9.3 / 0.9.9 - haven't retested with 0.9.11, the latest 0.9.x release as of this writing...)

thomaschaaf commented 7 years ago

You may only give these rights: https://aws.amazon.com/de/premiumsupport/knowledge-center/duplicate-master-user-mysql/

mclavel commented 6 years ago

hi @leftathome , i create a PR for this case (when the DB doesn't exist)