Skip to content

Commit 61d6d86

Browse files
Change the default for google_sql_database.deletion_policy to DELETE (#6936) (#4972)
Fixes hashicorp/terraform-provider-google#13206 Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 96369ca commit 61d6d86

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

.changelog/6936.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:note
2+
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.
3+
```
4+
```release-note:bug
5+
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.
6+
```

google-beta/resource_sql_database.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ a value of 'en_US.UTF8' at creation time.`,
7979
"deletion_policy": {
8080
Type: schema.TypeString,
8181
Optional: true,
82-
Default: "ABANDON",
82+
Default: "DELETE",
8383
Description: `The deletion policy for the database. Setting ABANDON allows the resource
8484
to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be
8585
deleted from the API if there are users other than cloudsqlsuperuser with access. Possible
86-
values are: "ABANDON".`,
86+
values are: "ABANDON", "DELETE". Defaults to "DELETE".`,
8787
},
8888
"project": {
8989
Type: schema.TypeString,
@@ -218,7 +218,7 @@ func resourceSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error {
218218

219219
// Explicitly set virtual fields to default values if unset
220220
if _, ok := d.GetOkExists("deletion_policy"); !ok {
221-
if err := d.Set("deletion_policy", "ABANDON"); err != nil {
221+
if err := d.Set("deletion_policy", "DELETE"); err != nil {
222222
return fmt.Errorf("Error setting deletion_policy: %s", err)
223223
}
224224
}
@@ -401,7 +401,7 @@ func resourceSQLDatabaseImport(d *schema.ResourceData, meta interface{}) ([]*sch
401401
d.SetId(id)
402402

403403
// Explicitly set virtual fields to default values on import
404-
if err := d.Set("deletion_policy", "ABANDON"); err != nil {
404+
if err := d.Set("deletion_policy", "DELETE"); err != nil {
405405
return nil, fmt.Errorf("Error setting deletion_policy: %s", err)
406406
}
407407

google-beta/resource_sql_database_generated_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ func TestAccSQLDatabase_sqlDatabaseDeletionPolicyExample(t *testing.T) {
8686
Config: testAccSQLDatabase_sqlDatabaseDeletionPolicyExample(context),
8787
},
8888
{
89-
ResourceName: "google_sql_database.database_deletion_policy",
90-
ImportState: true,
91-
ImportStateVerify: true,
89+
ResourceName: "google_sql_database.database_deletion_policy",
90+
ImportState: true,
91+
ImportStateVerify: true,
92+
ImportStateVerifyIgnore: []string{"deletion_policy"},
9293
},
9394
},
9495
})

website/docs/r/sql_database.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ The following arguments are supported:
121121
* `deletion_policy` - (Optional) The deletion policy for the database. Setting ABANDON allows the resource
122122
to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be
123123
deleted from the API if there are users other than cloudsqlsuperuser with access. Possible
124-
values are: "ABANDON".
124+
values are: "ABANDON", "DELETE". Defaults to "DELETE".
125125

126126

127127
## Attributes Reference

0 commit comments

Comments
 (0)