Skip to content
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

Change the default for google_sql_database.deletion_policy to DELETE #13226

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .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.
```
8 changes: 4 additions & 4 deletions google/resource_sql_database.go
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}

Expand Down
7 changes: 4 additions & 3 deletions google/resource_sql_database_generated_test.go
Expand Up @@ -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"},
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/sql_database.html.markdown
Expand Up @@ -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
Expand Down