Skip to content

Commit

Permalink
Add option to enable backup
Browse files Browse the repository at this point in the history
It's turn on by default
  • Loading branch information
wawrzek committed Oct 17, 2024
1 parent 36059f0 commit faa4a07
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_backup"></a> [backup](#input\_backup) | Switch to enable backups | `bool` | `true` | no |
| <a name="input_db-size"></a> [db-size](#input\_db-size) | DB size/type | `string` | `"db-f1-micro"` | no |
| <a name="input_db-version"></a> [db-version](#input\_db-version) | DB type and version (e.g. POSTGRES\_14) | `string` | `"POSTGRES_14"` | no |
| <a name="input_deletion-protection"></a> [deletion-protection](#input\_deletion-protection) | Delete protection of DB | `bool` | `true` | no |
Expand Down
7 changes: 7 additions & 0 deletions postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ resource "google_sql_database_instance" "this" {
private_network = var.network-id
}
}
dynamic "backup_configuration" {
for_each = var.backup ? [1] : []
content {
enabled = true
point_in_time_recovery_enabled = true
}
}
}
depends_on = [google_service_networking_connection.this]
}
Expand Down
6 changes: 6 additions & 0 deletions postgres/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "backup" {
default = true
description = "Switch to enable backups"
type = bool
}

variable "db-size" {
default = "db-f1-micro"
description = "DB size/type"
Expand Down

0 comments on commit faa4a07

Please sign in to comment.