petoju / terraform-provider-mysql

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

Crash apply grants role with "_" in name #151

Closed nicolas-fidel-wmx closed 1 month ago

nicolas-fidel-wmx commented 1 month ago

Hi there,

please follow these steps to ensure quick resolution of your issue.

The maintainer (petoju) manages this project in a free time and thus doesn't have plenty of time to resolve all the issues. With that mentioned, PRs are always welcome.

Provider version

Run terraform -v to show the version. If you are not running the latest version of this provider, please upgrade because your issue may have already been fixed.

Terraform v1.7.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v5.49.0
+ provider registry.terraform.io/hashicorp/random v3.6.1
+ provider registry.terraform.io/petoju/mysql v3.0.59

Your version of Terraform is out of date! The latest version
is 1.8.3. You can update by downloading from https://www.terraform.io/downloads.html

use 3.0.59 version

MySQL version and settings

mysql 8 on aws aurora

Terraform Configuration Files

In the ideal case, provide narrowed-down reproducer of your case. This should be a complete module with config connecting to localhost demonstrating the issue.

If you can, provide also docker command-line or docker-compose file starting mysql, which lead to the issue. That will remove any ambiguity regarding versions of tools and so on.

Debug Output

2024-05-13T11:57:59.698+0200 [INFO]  provider.terraform-provider-mysql_v3.0.59: 2024/05/13 11:57:59 [DEBUG] Executing statement: GRANT role_infra_grafana-on-call TO 'grafana_on_call'@'%': timestamp="2024-05-13T11:57:59.698+0200"
2024-05-13T11:57:59.702+0200 [ERROR] provider.terraform-provider-mysql_v3.0.59: Response contains error diagnostic: diagnostic_severity=ERROR tf_req_id=a5278784-c081-37bb-8369-584beee9a54c tf_resource_type=mysql_grant @module=sdk.proto tf_proto_version=5.4 diagnostic_detail="" tf_rpc=ApplyResourceChange tf_provider_addr=provider @caller=github.com/hashicorp/terraform-plugin-go@v0.22.2/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_summary="Error running SQL (GRANT role_infra_grafana-on-call TO 'grafana_on_call'@'%'): Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-on-call TO 'grafana_on_call'@'%'' at line 1" timestamp="2024-05-13T11:57:59.702+0200"
╷
│ Error: Error running SQL (GRANT role_infra_grafana-on-call TO 'grafana_on_call'@'%'): Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-on-call TO 'grafana_on_call'@'%'' at line 1
│
│   with module.role_infra_grafana_on_call.mysql_grant.grant_to_users["grafana_on_call"],
│   on .terraform/modules/role_infra_grafana_on_call/012/rds/aurora_mysql_role/grant_to_users.tf line 1, in resource "mysql_grant" "grant_to_users":
│    1: resource "mysql_grant" "grant_to_users" {

In case reproducing the issue needs multiple runs, provide more GitHub Gists.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened?

The problem is that the role is not backquote, it should be role to avoid this kind of error.

Actual Behavior

What actually happened?

Steps to Reproduce

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

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

Running on aws-aurora mysql-8

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

petoju commented 1 month ago

It's dash that's was the issue. Fixed in version 3.0.60