Skip to content

Commit d694f58

Browse files
Add preferred_zone in clone context of sql database instance resource (#8990) (#15971)
Signed-off-by: Modular Magician <[email protected]>
1 parent 7664ad9 commit d694f58

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

.changelog/8990.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
sql: added `preferred_zone` field to `google_sql_database_instance` resource
3+
```

google/services/sql/resource_sql_database_instance.go

+6
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,11 @@ is set to true. Defaults to ZONAL.`,
945945
DiffSuppressFunc: tpgresource.TimestampDiffSuppress(time.RFC3339Nano),
946946
Description: `The timestamp of the point in time that should be restored.`,
947947
},
948+
"preferred_zone": {
949+
Type: schema.TypeString,
950+
Optional: true,
951+
Description: `(Point-in-time recovery for PostgreSQL only) Clone to an instance in the specified zone. If no zone is specified, clone to the same zone as the source instance.`,
952+
},
948953
"database_names": {
949954
Type: schema.TypeList,
950955
Optional: true,
@@ -1316,6 +1321,7 @@ func expandCloneContext(configured []interface{}) (*sqladmin.CloneContext, strin
13161321

13171322
return &sqladmin.CloneContext{
13181323
PointInTime: _cloneConfiguration["point_in_time"].(string),
1324+
PreferredZone: _cloneConfiguration["preferred_zone"].(string),
13191325
DatabaseNames: databaseNames,
13201326
AllocatedIpRange: _cloneConfiguration["allocated_ip_range"].(string),
13211327
}, _cloneConfiguration["source_instance_name"].(string)

google/services/sql/resource_sql_database_instance_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -3729,6 +3729,7 @@ resource "google_sql_database_instance" "instance" {
37293729
clone {
37303730
source_instance_name = data.google_sql_backup_run.backup.instance
37313731
point_in_time = data.google_sql_backup_run.backup.start_time
3732+
preferred_zone = "us-central1-b"
37323733
}
37333734
37343735
deletion_protection = false

website/docs/r/sql_database_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ The optional `clone` block supports:
486486

487487
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
488488

489+
* `preferred_zone` - (Optional) (Point-in-time recovery for PostgreSQL only) Clone to an instance in the specified zone. If no zone is specified, clone to the same zone as the source instance. [clone-unavailable-instance](https://cloud.google.com/sql/docs/postgres/clone-instance#clone-unavailable-instance)
490+
489491
* `database_names` - (Optional) (SQL Server only, use with `point_in_time`) Clone only the specified databases from the source instance. Clone all databases if empty.
490492

491493
* `allocated_ip_range` - (Optional) The name of the allocated ip range for the private ip CloudSQL instance. For example: "google-managed-services-default". If set, the cloned instance ip will be created in the allocated range. The range name must comply with [RFC 1035](https://tools.ietf.org/html/rfc1035). Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])?.

0 commit comments

Comments
 (0)