Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit f1d7314

Browse files
committed
Add point in time recovery option in backend coniguration
1 parent 18d0241 commit f1d7314

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

modules/cloud-sql/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ resource "google_sql_database_instance" "master" {
6464
}
6565

6666
backup_configuration {
67-
binary_log_enabled = local.actual_binary_log_enabled
68-
enabled = var.backup_enabled
69-
start_time = var.backup_start_time
67+
binary_log_enabled = local.actual_binary_log_enabled
68+
enabled = var.backup_enabled
69+
start_time = var.backup_start_time
70+
point_in_time_recovery_enabled = local.is_postgres ? null : var.postgres_point_in_time_recovery_enabled
7071
}
7172

7273
maintenance_window {
@@ -121,7 +122,7 @@ resource "google_sql_user" "default" {
121122
name = var.master_user_name
122123
instance = google_sql_database_instance.master.name
123124
# Postgres users don't have hosts, so the API will ignore this value which causes Terraform to attempt
124-
# to recreate the user each time.
125+
# to recreate the user each time
125126
# See https://github.com/terraform-providers/terraform-provider-google/issues/1526 for more information.
126127
host = local.is_postgres ? null : var.master_user_host
127128
password = var.master_user_password

modules/cloud-sql/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ variable "backup_start_time" {
8787
default = "04:00"
8888
}
8989

90+
variable "postgres_point_in_time_recovery_enabled" {
91+
description = "Will restart database if enabled after instance creation - only applicable to PostgreSQL"
92+
type = bool
93+
default = false
94+
}
95+
9096
variable "mysql_binary_log_enabled" {
9197
description = "Set to false if you want to disable binary logs - only applicable to MySQL. Note, when using failover or read replicas, master and existing backups need to have binary_log_enabled=true set."
9298
type = bool

0 commit comments

Comments
 (0)