-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[arm_sql_database] - Make collation case insensitive #3137
Conversation
hi @hbuckle Thanks for this PR :) Whilst historically we've made some fields in the AzureRM Provider case-insensitive - we've found that this can lead to issues where the casing is important within the Azure API, such that allowing these to be case-insensitive can lead to hard to reproduce issues (for example, the DataBricks API behaves differently for Out of interest what's the issue/diff that you're seeing here, and are you seeing this on a older resource or a newly created one? Thanks! |
This was to address an issue I saw after I created an empty database with Terraform, then restored an existing database from another server over the top of it. The casing of resource "azurerm_sql_database" "database" {
name = "database"
resource_group_name = "${azurerm_resource_group.sql.name}"
location = "${azurerm_resource_group.sql.location}"
server_name = "${azurerm_sql_server.sql_server.name}"
collation = "SQL_LATIN1_GENERAL_CP1_CI_AS"
max_size_bytes = "268435456000"
create_mode = "Default"
requested_service_objective_name = "ElasticPool"
elastic_pool_name = "${azurerm_mssql_elasticpool.sql.name}"
} This was the plan output after restoring the other database
|
I wouldn't have thought the API would be case sensitive on collation as it's a database setting, but I agree it's worth checking. |
SQL doesn't care about the case of the collation. This is actually a great find and great PR that will save me and probably others some headaches Update: I actually think the Looked at the sqldatabase name and it should have the suppress as well. If the database name went to alternative case after restore. |
We are purposely not moving towards case insensitivity on string fields for a variety of reasons, from API's being inconsistent in their casing to if you did want to change the casing of the coalition, after this PR you can no longer. Terraform will warn of such changes and in this case you can simply change your terraform config to use |
@katbyte In the case that was presented, it is a valid If I restore a DB, it should not destroy it on next terraform execution just because the collation is in a different case. My suggestion was to use it on "most" resource parameters, API might not be one of them. |
To confirm, I just performed the following test resource "azurerm_resource_group" "resource_group" {
name = "collation"
location = "uksouth"
}
resource "azurerm_sql_server" "test" {
name = "hbtestcollation"
resource_group_name = "${azurerm_resource_group.resource_group.name}"
location = "uksouth"
version = "12.0"
administrator_login = "xxx"
administrator_login_password = "xxx"
}
resource "azurerm_sql_database" "test" {
name = "mysqldatabase"
resource_group_name = "${azurerm_resource_group.resource_group.name}"
location = "uksouth"
server_name = "${azurerm_sql_server.test.name}"
collation = "SQL_LATIN1_GENERAL_CP1_CI_AS"
} $uri = "https://management.azure.com/subscriptions/xxx/resourceGroups/collation/providers/Microsoft.Sql/servers/hbtestcollation/databases/mysqldatabase?api-version=2017-10-01-preview"
$update = @{
properties = @{
collation = "sql_latin1_general_cp1_ci_as"
}
} | ConvertTo-Json -Depth 99
Invoke-RestMethod $uri -Method Patch -Authentication Bearer -Token $token -Body $update -ContentType "application/json"
Invoke-RestMethod $uri -Authentication Bearer -Token $token -Method Get
SQL_LATIN1_GENERAL_CP1_CI_AS So it seems the API ignores the case in this instance |
@tombuildsstuff In light of the above test would it be possible to merge this? If not I'll look into an alternative workaround. Thanks! |
Case sensitivity in the provider has been an ongoing debate internally as we would like to generally be one or the other overall. As azure is a mixed bag (with some APIs case matters and other it does not) it rules out the possibility of the provider being primarily case insensitive. Case sensitivity is compatible with a case insensitive API (provided it doesn't change the case!) while the other way around is not. We strive for consistency across resources and properties so users can make certain assumptions and expect a uniform behaviour even if the APIs might not behave as such. Additionally as APIs evolve and change over time their sensitivity to case may change (as has happened. Switching to more case sensitivity means this is now no longer will affect terraform configurations when the switch. Using For all of these reasons we have decided to try and take the provider towards more case sensitivity and consistency except in cases where it is absolutely necessary such as when the APIs are broken and require us to ignore it until they are fixed. I hope this gives some insight into why we are so hesitant to mark any property as case insensitive to even if it may make some workflows easier. |
hey @hbuckle Sorry for the delayed movement here - we've been waiting to chat about this as a team. From our side we're trying to determine our criteria for making a field case sensitive, which we believe boils down to:
As such, in this specific case we believe it makes sense for this field to be case insensitive - since the API ignores the difference on casing during an update. Given this we believe we should make this field case sensitive (and merge this PR) to ensure the behaviour matches the Azure API here - which we'll do as a part of #2688. Apologies for the delay in reviewing this, as mentioned we've been trying to clarify the requirements for case sensitivity. Thanks! |
This has been released in version 1.28.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 1.28.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
No description provided.