Skip to content

Commit a662c33

Browse files
Added Cloud SQL postgres + authorized network example (#5792) (#4110)
* Added Cloud SQL postgres with authorized network example for inclusion in CGC docs * Added missing primary_resource_type * Fixed deletion protection * Added Cloud SQL postgres + authorized network example Signed-off-by: Modular Magician <[email protected]>
1 parent 3a251ec commit a662c33

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

.changelog/5792.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```release-note:none
2+
```

google-beta/resource_cgc_snippet_generated_test.go

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ func TestAccCGCSnippet_sqlSqlserverInstanceAuthorizedNetworkExample(t *testing.T
279279
t.Parallel()
280280

281281
context := map[string]interface{}{
282-
"random_suffix": randString(t, 10),
282+
"deletion_protection": false,
283+
"random_suffix": randString(t, 10),
283284
}
284285

285286
vcrTest(t, resource.TestCase{
@@ -321,6 +322,52 @@ resource "google_sql_database_instance" "default" {
321322
`, context)
322323
}
323324

325+
func TestAccCGCSnippet_sqlPostgresInstanceAuthorizedNetworkExample(t *testing.T) {
326+
t.Parallel()
327+
328+
context := map[string]interface{}{
329+
"deletion_protection": false,
330+
"random_suffix": randString(t, 10),
331+
}
332+
333+
vcrTest(t, resource.TestCase{
334+
PreCheck: func() { testAccPreCheck(t) },
335+
Providers: testAccProviders,
336+
Steps: []resource.TestStep{
337+
{
338+
Config: testAccCGCSnippet_sqlPostgresInstanceAuthorizedNetworkExample(context),
339+
},
340+
{
341+
ResourceName: "google_sql_database_instance.default",
342+
ImportState: true,
343+
ImportStateVerify: true,
344+
ImportStateVerifyIgnore: []string{"deletion_protection"},
345+
},
346+
},
347+
})
348+
}
349+
350+
func testAccCGCSnippet_sqlPostgresInstanceAuthorizedNetworkExample(context map[string]interface{}) string {
351+
return Nprintf(`
352+
resource "google_sql_database_instance" "default" {
353+
name = "tf-test-postgres-instance-with-authorized-network%{random_suffix}"
354+
region = "us-central1"
355+
database_version = "POSTGRES_12"
356+
settings {
357+
tier = "db-custom-2-7680"
358+
ip_configuration {
359+
authorized_networks {
360+
name = "Network Name"
361+
value = "192.0.2.0/24"
362+
expiration_time = "3021-11-15T16:19:00.094Z"
363+
}
364+
}
365+
}
366+
deletion_protection = "%{deletion_protection}"
367+
}
368+
`, context)
369+
}
370+
324371
func TestAccCGCSnippet_storageNewBucketExample(t *testing.T) {
325372
t.Parallel()
326373

0 commit comments

Comments
 (0)