Skip to content

Commit

Permalink
Add preferred_zone in clone context of sql database instance resource (
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhaskar2 authored Sep 25, 2023
1 parent d1dc839 commit aef0da0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,11 @@ is set to true. Defaults to ZONAL.`,
DiffSuppressFunc: tpgresource.TimestampDiffSuppress(time.RFC3339Nano),
Description: `The timestamp of the point in time that should be restored.`,
},
"preferred_zone": {
Type: schema.TypeString,
Optional: true,
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.`,
},
"database_names": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -1317,6 +1322,7 @@ func expandCloneContext(configured []interface{}) (*sqladmin.CloneContext, strin

return &sqladmin.CloneContext{
PointInTime: _cloneConfiguration["point_in_time"].(string),
PreferredZone: _cloneConfiguration["preferred_zone"].(string),
DatabaseNames: databaseNames,
AllocatedIpRange: _cloneConfiguration["allocated_ip_range"].(string),
}, _cloneConfiguration["source_instance_name"].(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3727,6 +3727,7 @@ resource "google_sql_database_instance" "instance" {
clone {
source_instance_name = data.google_sql_backup_run.backup.instance
point_in_time = data.google_sql_backup_run.backup.start_time
preferred_zone = "us-central1-b"
}
deletion_protection = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ The optional `clone` block supports:

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".

* `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)

* `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.

* `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])?.
Expand Down

0 comments on commit aef0da0

Please sign in to comment.