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

Plugin crashing when creating resource mysql grant #128

Closed ehognestad closed 2 months ago

ehognestad commented 3 months ago

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

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

Terraform v1.5.7 on darwin_amd64

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

provider "mysql" {
  alias    = "local"
  endpoint = "127.0.0.1:3309"
  username = var.rds_admin_username
  password = data.aws_ssm_parameter.rds_password.value
}

resource "random_password" "jj" {
  length           = 24
  special          = true
  min_special      = 2
  override_special = "!#$%^&*()-_=+[]{}<>:?"
  keepers = {
    password_version = 1
  }
}

resource "mysql_user" "jj" {
  provider           = mysql.local
  user               = ""
  plaintext_password = random_password.jj.result
  host               = "%"
  tls_option         = "NONE"
}

resource "mysql_grant" "jj" {
  provider   = mysql.local
  user       = mysql_user.jj.user
  host       = "%"
  database   = var.rds_database_name
  privileges = ["INSERT", "UPDATE", "SELECT"]
  depends_on = [
    mysql_user.jj
  ]
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

https://gist.github.com/ehognestad/ae66776710d15117b0d43e630c7f1064

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 created mysql user should have been granted certain privileges

Actual Behavior

What actually happened? The mysql provider crashed with the above gist output

Steps to Reproduce

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

  1. run terraform applywith a resource mysql_user and a mysql_grant

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? This was run against a AWS RDS environment, through a ssh tunnel, with a jump host. It was working before this latest provider version.

References

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

ehognestad commented 3 months ago

I tried to downgrade to provider version: 3.0.48 and it is also crashing.

ehognestad commented 3 months ago

I found out what caused the crash of the provider actually, the username of the user was an empty string in the mysql_user resource;

resource "mysql_user" "jj" { provider = mysql.local user = "" plaintext_password = random_password.jj.result host = "%" tls_option = "NONE" }

This should probably have a more elegant error output and not crash the plugin.

petoju commented 2 months ago

This was fixed as a part of provider version 3.0.55 - thanks @jessedearing