Azure / azure-mysql

Azure Database for MySQL (fully managed service for MySQL in Azure)
MIT License
52 stars 75 forks source link

Mysql Flexible server admin user does not support hyphen character #287

Open r4kh1m opened 3 months ago

r4kh1m commented 3 months ago

After in-place auto-migration from single to Flexible server, the Server admin login name moved to the Flexible one containing hyphen (-).

Now, we need to import the migrated Flexible server to the Terraform.

The validation is happening on the API side because I am not able to create the sample server with the hyphen:

az mysql flexible-server create --location westeurope --resource-group test-rg --name example1232453534653 --admin-user "with-hyphen"

(InvalidParameterValue) Invalid value given for parameter administratorLogin. Specify a valid parameter value.
Code: InvalidParameterValue
Message: Invalid value given for parameter administratorLogin. Specify a valid parameter value.

This issue is blocking: https://github.com/hashicorp/terraform-provider-azurerm/issues/26658

derekrprice commented 2 months ago

Yes. Terraform refuses the original admin username and wants to destroy the new mirror server and all its data if you try to change it. This is somewhat urgent since all the Single Server deployments become inoperable on September 16th, 2024 (12 days from this posting). The workaround is to not manage the new server via Terraform, but that's pretty inconvenient for those who already built and manage their infrastructure that way.

derekrprice commented 2 months ago

Ok, this works as a workaround too:

    lifecycle {
        # The API rejects the pre-existing hyphen in our username and changing the administrator_login
        # recreates the resource, destroying its data.  Just ignore this difference.
        ignore_changes = [administrator_login]
    }