Skip to content

Commit

Permalink
Added Cloud SQL postgres + authorized network example (#5792) (#4110)
Browse files Browse the repository at this point in the history
* 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 <magic-modules@google.com>
  • Loading branch information
modular-magician authored Mar 8, 2022
1 parent 3a251ec commit a662c33
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .changelog/5792.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```release-note:none
```
49 changes: 48 additions & 1 deletion google-beta/resource_cgc_snippet_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ func TestAccCGCSnippet_sqlSqlserverInstanceAuthorizedNetworkExample(t *testing.T
t.Parallel()

context := map[string]interface{}{
"random_suffix": randString(t, 10),
"deletion_protection": false,
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -321,6 +322,52 @@ resource "google_sql_database_instance" "default" {
`, context)
}

func TestAccCGCSnippet_sqlPostgresInstanceAuthorizedNetworkExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"deletion_protection": false,
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCGCSnippet_sqlPostgresInstanceAuthorizedNetworkExample(context),
},
{
ResourceName: "google_sql_database_instance.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
},
})
}

func testAccCGCSnippet_sqlPostgresInstanceAuthorizedNetworkExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_sql_database_instance" "default" {
name = "tf-test-postgres-instance-with-authorized-network%{random_suffix}"
region = "us-central1"
database_version = "POSTGRES_12"
settings {
tier = "db-custom-2-7680"
ip_configuration {
authorized_networks {
name = "Network Name"
value = "192.0.2.0/24"
expiration_time = "3021-11-15T16:19:00.094Z"
}
}
}
deletion_protection = "%{deletion_protection}"
}
`, context)
}

func TestAccCGCSnippet_storageNewBucketExample(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit a662c33

Please sign in to comment.