From 63683563f27be5364a7b17c3e6b74f881e66d9e3 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 19 Jul 2022 14:07:16 -0700 Subject: [PATCH] Remove collation from update request and make collation non-updatable (#6298) (#12131) Signed-off-by: Modular Magician --- .changelog/6298.txt | 3 +++ google/resource_sql_database_instance.go | 4 +++ google/resource_sql_database_instance_test.go | 27 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 .changelog/6298.txt diff --git a/.changelog/6298.txt b/.changelog/6298.txt new file mode 100644 index 00000000000..2ba06e6ecbb --- /dev/null +++ b/.changelog/6298.txt @@ -0,0 +1,3 @@ +```release-note:bug +sql: fixed an issue in `google_sql_database_instance` where updates would fail because of the `collation` field +``` diff --git a/google/resource_sql_database_instance.go b/google/resource_sql_database_instance.go index 3974cdfde19..6553abe20f0 100644 --- a/google/resource_sql_database_instance.go +++ b/google/resource_sql_database_instance.go @@ -267,6 +267,7 @@ is set to true.`, "collation": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: `The name of server instance collation.`, }, "database_flags": { @@ -1305,6 +1306,9 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) Settings: expandSqlDatabaseInstanceSettings(d.Get("settings").([]interface{})), } + // Collation cannot be included in the update request + instance.Settings.Collation = "" + // Lock on the master_instance_name just in case updating any replica // settings causes operations on the master. if v, ok := d.GetOk("master_instance_name"); ok { diff --git a/google/resource_sql_database_instance_test.go b/google/resource_sql_database_instance_test.go index b03c3a6cd2a..e08ce4257fc 100644 --- a/google/resource_sql_database_instance_test.go +++ b/google/resource_sql_database_instance_test.go @@ -222,6 +222,16 @@ func TestAccSqlDatabaseInstance_basicMSSQL(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"}, }, + { + Config: fmt.Sprintf( + testGoogleSqlDatabaseInstance_update_mssql, databaseName, rootPassword), + }, + { + ResourceName: "google_sql_database_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"}, + }, }, }) } @@ -1221,6 +1231,23 @@ resource "google_sql_database_instance" "instance" { } ` +var testGoogleSqlDatabaseInstance_update_mssql = ` +resource "google_sql_database_instance" "instance" { + name = "%s" + database_version = "SQLSERVER_2019_STANDARD" + root_password = "%s" + deletion_protection = false + settings { + tier = "db-custom-1-3840" + collation = "Polish_CI_AS" + ip_configuration { + ipv4_enabled = true + require_ssl = true + } + } +} +` + func testGoogleSqlDatabaseInstance_ActiveDirectoryConfig(databaseName, networkName, addressRangeName, rootPassword, adDomainName string) string { return fmt.Sprintf(` data "google_compute_network" "servicenet" {