Skip to content

Commit 7b9d5ad

Browse files
Added examples for Cloud SQL backup retention (#5809) (#11294)
Signed-off-by: Modular Magician <[email protected]>
1 parent 6fb31ef commit 7b9d5ad

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.changelog/5809.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```release-note:none
2+
```

google/resource_cgc_snippet_generated_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,53 @@ resource "google_sql_database_instance" "default" {
365365
`, context)
366366
}
367367

368+
func TestAccCGCSnippet_sqlSqlserverInstanceBackupRetentionExample(t *testing.T) {
369+
t.Parallel()
370+
371+
context := map[string]interface{}{
372+
"deletion_protection": false,
373+
"random_suffix": randString(t, 10),
374+
}
375+
376+
vcrTest(t, resource.TestCase{
377+
PreCheck: func() { testAccPreCheck(t) },
378+
Providers: testAccProviders,
379+
Steps: []resource.TestStep{
380+
{
381+
Config: testAccCGCSnippet_sqlSqlserverInstanceBackupRetentionExample(context),
382+
},
383+
{
384+
ResourceName: "google_sql_database_instance.default",
385+
ImportState: true,
386+
ImportStateVerify: true,
387+
ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"},
388+
},
389+
},
390+
})
391+
}
392+
393+
func testAccCGCSnippet_sqlSqlserverInstanceBackupRetentionExample(context map[string]interface{}) string {
394+
return Nprintf(`
395+
resource "google_sql_database_instance" "default" {
396+
name = "tf-test-sqlserver-instance-backup-retention%{random_suffix}"
397+
region = "us-central1"
398+
database_version = "SQLSERVER_2017_STANDARD"
399+
root_password = "INSERT-PASSWORD-HERE"
400+
settings {
401+
tier = "db-custom-2-7680"
402+
backup_configuration {
403+
enabled = true
404+
backup_retention_settings {
405+
retained_backups = 365
406+
retention_unit = "COUNT"
407+
}
408+
}
409+
}
410+
deletion_protection = "%{deletion_protection}"
411+
}
412+
`, context)
413+
}
414+
368415
func TestAccCGCSnippet_storageNewBucketExample(t *testing.T) {
369416
t.Parallel()
370417

0 commit comments

Comments
 (0)