diff --git a/.changelog/6936.txt b/.changelog/6936.txt new file mode 100644 index 00000000000..719e28dc222 --- /dev/null +++ b/.changelog/6936.txt @@ -0,0 +1,6 @@ +```release-note:note +sql: fixed an issue where `google_sql_database` was abandoned by default as of version `4.45.0`. Users who have upgraded to `4.45.0` or `4.46.0` will see a diff when running their next `terraform apply` after upgrading this version, indicating the `deletion_policy` field's value has changed from `"ABANDON"` to `"DELETE"`. This will create a no-op call against the API, but can otherwise be safely applied. +``` +```release-note:bug +sql: fixed an issue where `google_sql_database` was abandoned by default as of version `4.45.0`. Users who have upgraded to `4.45.0` or `4.46.0` will see a diff when running their next `terraform apply` after upgrading this version, indicating the `deletion_policy` field's value has changed from `"ABANDON"` to `"DELETE"`. This will create a no-op call against the API, but can otherwise be safely applied. +``` diff --git a/google/resource_sql_database.go b/google/resource_sql_database.go index 385efa0e28d..c357bdc1864 100644 --- a/google/resource_sql_database.go +++ b/google/resource_sql_database.go @@ -79,11 +79,11 @@ a value of 'en_US.UTF8' at creation time.`, "deletion_policy": { Type: schema.TypeString, Optional: true, - Default: "ABANDON", + Default: "DELETE", Description: `The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible -values are: "ABANDON".`, +values are: "ABANDON", "DELETE". Defaults to "DELETE".`, }, "project": { Type: schema.TypeString, @@ -218,7 +218,7 @@ func resourceSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error { // Explicitly set virtual fields to default values if unset if _, ok := d.GetOkExists("deletion_policy"); !ok { - if err := d.Set("deletion_policy", "ABANDON"); err != nil { + if err := d.Set("deletion_policy", "DELETE"); err != nil { return fmt.Errorf("Error setting deletion_policy: %s", err) } } @@ -401,7 +401,7 @@ func resourceSQLDatabaseImport(d *schema.ResourceData, meta interface{}) ([]*sch d.SetId(id) // Explicitly set virtual fields to default values on import - if err := d.Set("deletion_policy", "ABANDON"); err != nil { + if err := d.Set("deletion_policy", "DELETE"); err != nil { return nil, fmt.Errorf("Error setting deletion_policy: %s", err) } diff --git a/google/resource_sql_database_generated_test.go b/google/resource_sql_database_generated_test.go index 115f6dd5bb8..98189c022a3 100644 --- a/google/resource_sql_database_generated_test.go +++ b/google/resource_sql_database_generated_test.go @@ -86,9 +86,10 @@ func TestAccSQLDatabase_sqlDatabaseDeletionPolicyExample(t *testing.T) { Config: testAccSQLDatabase_sqlDatabaseDeletionPolicyExample(context), }, { - ResourceName: "google_sql_database.database_deletion_policy", - ImportState: true, - ImportStateVerify: true, + ResourceName: "google_sql_database.database_deletion_policy", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_policy"}, }, }, }) diff --git a/website/docs/r/sql_database.html.markdown b/website/docs/r/sql_database.html.markdown index b9c98138efd..0527327b481 100644 --- a/website/docs/r/sql_database.html.markdown +++ b/website/docs/r/sql_database.html.markdown @@ -121,7 +121,7 @@ The following arguments are supported: * `deletion_policy` - (Optional) The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible -values are: "ABANDON". +values are: "ABANDON", "DELETE". Defaults to "DELETE". ## Attributes Reference