Skip to content

Commit 8ce1a5b

Browse files
Cloud SQL mysql replica sample for cgc (#5859) (#11371)
Signed-off-by: Modular Magician <[email protected]>
1 parent adb6e10 commit 8ce1a5b

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

.changelog/5859.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

+61
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,67 @@ resource "google_sql_database_instance" "default" {
412412
`, context)
413413
}
414414

415+
func TestAccCGCSnippet_sqlMysqlInstanceReplicaExample(t *testing.T) {
416+
t.Parallel()
417+
418+
context := map[string]interface{}{
419+
"deletion_protection": false,
420+
"random_suffix": randString(t, 10),
421+
}
422+
423+
vcrTest(t, resource.TestCase{
424+
PreCheck: func() { testAccPreCheck(t) },
425+
Providers: testAccProviders,
426+
Steps: []resource.TestStep{
427+
{
428+
Config: testAccCGCSnippet_sqlMysqlInstanceReplicaExample(context),
429+
},
430+
{
431+
ResourceName: "google_sql_database_instance.read_replica",
432+
ImportState: true,
433+
ImportStateVerify: true,
434+
ImportStateVerifyIgnore: []string{"deletion_protection"},
435+
},
436+
},
437+
})
438+
}
439+
440+
func testAccCGCSnippet_sqlMysqlInstanceReplicaExample(context map[string]interface{}) string {
441+
return Nprintf(`
442+
resource "google_sql_database_instance" "primary" {
443+
name = "tf-test-mysql-primary-instance-name%{random_suffix}"
444+
region = "europe-west4"
445+
database_version = "MYSQL_8_0"
446+
settings {
447+
tier = "db-n1-standard-2"
448+
backup_configuration {
449+
enabled = "true"
450+
binary_log_enabled = "true"
451+
}
452+
}
453+
deletion_protection = "%{deletion_protection}"
454+
}
455+
456+
resource "google_sql_database_instance" "read_replica" {
457+
name = "tf-test-mysql-replica-instance-name%{random_suffix}"
458+
master_instance_name = google_sql_database_instance.primary.name
459+
region = "europe-west4"
460+
database_version = "MYSQL_8_0"
461+
462+
replica_configuration {
463+
failover_target = false
464+
}
465+
466+
settings {
467+
tier = "db-n1-standard-2"
468+
availability_type = "ZONAL"
469+
disk_size = "100"
470+
}
471+
deletion_protection = "%{deletion_protection}"
472+
}
473+
`, context)
474+
}
475+
415476
func TestAccCGCSnippet_storageNewBucketExample(t *testing.T) {
416477
t.Parallel()
417478

0 commit comments

Comments
 (0)