Closed sebastianwahn closed 6 years ago
I have faced a very similar issue today. My problem was that my database name included a hyphen ("-").
I see that you have your database name also with a - (hyphen), which is not supported by default.
I don't know if you just wrote the hyphen because it is a habit or you database name really includes a hyphen.
I hope this helps you or anyone stumbling over this issue.
You can use backticks in the database name and it works :)
resource "mysql_grant" "some-grant" {
user = "${mysql_user.some-user.user}"
host = "${mysql_user.some-user.host}"
database = "`${mysql_database.some-database.name}`"
privileges = [
"ALTER",
"CREATE",
"DELETE",
"DROP",
"INDEX",
"INSERT",
"LOCK TABLES",
"SELECT",
"UPDATE"
]
}
Thats ridiculous! How is it possible that Terraform doesn't escape database names .__.
@moxli My database really contains hyphens, at least at this point. I changed it after I faced this issue. @nunofernandes Thanks for the hint of escaping the names.
Isn't the mysql-provider able to escape database names on its own?
@sebastianwahn @moxli I do not have feeling this is anyhow related the core of terraform
.
This is just how this provider was written. This bug should not be so difficult to be fixed. I will try to have a look at that.
This is a duplicate of #20. I've addressed it in #45. Closing this out for now.
When creating a grant resource for a user and a database, the grant is not created, failing with "Error 1046: No database selected".
This is due to the fact, that the minus character "-" is not allowed in a GRANT statement (for MariaDB). Therefore i suggest, to check the database name to only allow "_" characters instead of "-".
Currently, the database is created, but the grant can not be given to the user. I would expect that the database is also not created, since the database name is not allowed in all SQL statements.
Terraform Version
0.11.1
Affected Resource(s)
Terraform Configuration Files
mysql_database resource:
mysql_grant resource:
(shortened) Debug Output
According to the debug log, it will generate following SQL statement:
Which is not a valid SQL statement for MariaDB.
Expected Behavior
The GRANT statement is executed properly.
Actual Behavior
terraform apply
fails withError 1046: No database selected
Steps to Reproduce
Let it fail (with above resources):
terraform apply
Let it succeed:
terraform apply
Important Factoids
Running on AWS RDS using MariaDB 10.1.26