Skip to content

Commit

Permalink
feat: Add support for backup_configuration to mssql database submodule (
Browse files Browse the repository at this point in the history
  • Loading branch information
odise committed Sep 14, 2020
1 parent c8ae88a commit bed1cb4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/mssql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The following dependency must be available for SQL Server module:
| additional\_users | A list of users to be created in your cluster | object | `<list>` | no |
| authorized\_gae\_applications | The authorized gae applications for the Cloud SQL instances | list(string) | `<list>` | no |
| availability\_type | The availability type for the master instance.This is only used to set up high availability for the MSSQL instance. Can be either `ZONAL` or `REGIONAL`. | string | `"ZONAL"` | no |
| backup\_configuration | The database backup configuration. | object | `<map>` | no |
| create\_timeout | The optional timout that is applied to limit long database creates. | string | `"15m"` | no |
| database\_flags | The database flags for the master instance. See [more details](https://cloud.google.com/sql/docs/sqlserver/flags) | object | `<list>` | no |
| database\_version | The database version to use: SQLSERVER_2017_STANDARD, SQLSERVER_2017_ENTERPRISE, SQLSERVER_2017_EXPRESS, or SQLSERVER_2017_WEB | string | `"SQLSERVER_2017_STANDARD"` | no |
Expand Down
9 changes: 9 additions & 0 deletions modules/mssql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ resource "google_sql_database_instance" "default" {
activation_policy = var.activation_policy
availability_type = var.availability_type
authorized_gae_applications = var.authorized_gae_applications
dynamic "backup_configuration" {
for_each = var.backup_configuration.enabled ? [var.backup_configuration] : []
content {
binary_log_enabled = lookup(backup_configuration.value, "binary_log_enabled", null)
enabled = lookup(backup_configuration.value, "enabled", null)
start_time = lookup(backup_configuration.value, "start_time", null)
point_in_time_recovery_enabled = lookup(backup_configuration.value, "point_in_time_recovery_enabled", null)
}
}
dynamic "ip_configuration" {
for_each = [local.ip_configurations[local.ip_configuration_enabled ? "enabled" : "disabled"]]
content {
Expand Down
16 changes: 16 additions & 0 deletions modules/mssql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ variable "ip_configuration" {
}
}

variable "backup_configuration" {
description = "The database backup configuration."
type = object({
binary_log_enabled = bool
enabled = bool
point_in_time_recovery_enabled = bool
start_time = string
})
default = {
binary_log_enabled = null
enabled = false
point_in_time_recovery_enabled = null
start_time = null
}
}

variable "db_name" {
description = "The name of the default database to create"
type = string
Expand Down

0 comments on commit bed1cb4

Please sign in to comment.