Skip to content

Commit aef0da0

Browse files
authored
Add preferred_zone in clone context of sql database instance resource (#8990)
1 parent d1dc839 commit aef0da0

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.erb

+6
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,11 @@ is set to true. Defaults to ZONAL.`,
946946
DiffSuppressFunc: tpgresource.TimestampDiffSuppress(time.RFC3339Nano),
947947
Description: `The timestamp of the point in time that should be restored.`,
948948
},
949+
"preferred_zone": {
950+
Type: schema.TypeString,
951+
Optional: true,
952+
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.`,
953+
},
949954
"database_names": {
950955
Type: schema.TypeList,
951956
Optional: true,
@@ -1317,6 +1322,7 @@ func expandCloneContext(configured []interface{}) (*sqladmin.CloneContext, strin
13171322

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

mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -3727,6 +3727,7 @@ resource "google_sql_database_instance" "instance" {
37273727
clone {
37283728
source_instance_name = data.google_sql_backup_run.backup.instance
37293729
point_in_time = data.google_sql_backup_run.backup.start_time
3730+
preferred_zone = "us-central1-b"
37303731
}
37313732
37323733
deletion_protection = false

mmv1/third_party/terraform/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)