Skip to content

Commit

Permalink
feat!: Add deny_maintenance_period for MySQL, MsSQL, PostgreSQL…
Browse files Browse the repository at this point in the history
… and safer_sql (#399)

Co-authored-by: g-awmalik <[email protected]>
  • Loading branch information
aniketkumarj and g-awmalik authored Jan 9, 2023
1 parent cc39074 commit 55f4206
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ The root module has been deprecated. Please switch to using one of the submodule
### Installation Dependencies

- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin >= v4.4.0
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin >= v4.45.0

The following dependency must be available for SQL Server module:

- [Terraform Provider Beta for GCP](https://github.com/terraform-providers/terraform-provider-google-beta) plugin >= v4.22.0
- [Terraform Provider Beta for GCP](https://github.com/terraform-providers/terraform-provider-google-beta) plugin >= v4.45.0

### Configure a Service Account

Expand Down
3 changes: 2 additions & 1 deletion modules/mssql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The following dependency must be available for SQL Server module:

- [Terraform Provider Beta for GCP](https://github.com/terraform-providers/terraform-provider-google-beta) plugin >= 4.22.0
- [Terraform Provider Beta for GCP](https://github.com/terraform-providers/terraform-provider-google-beta) plugin >= 4.45.0

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs
Expand All @@ -23,6 +23,7 @@ The following dependency must be available for SQL Server module:
| db\_name | The name of the default database to create | `string` | `"default"` | no |
| delete\_timeout | The optional timeout that is applied to limit long database deletes. | `string` | `"30m"` | no |
| deletion\_protection | Used to block Terraform from deleting a SQL Instance. | `bool` | `true` | no |
| deny\_maintenance\_period | The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/sqlserver/maintenance) | <pre>list(object({<br> end_date = string<br> start_date = string<br> time = string<br> }))</pre> | `[]` | no |
| disk\_autoresize | Configuration to increase storage size. | `bool` | `true` | no |
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
| disk\_size | The disk size for the master instance. | `number` | `10` | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/mssql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ resource "google_sql_database_instance" "default" {
}
}
}
dynamic "deny_maintenance_period" {
for_each = var.deny_maintenance_period
content {
end_date = lookup(deny_maintenance_period.value, "end_date", null)
start_date = lookup(deny_maintenance_period.value, "start_date", null)
time = lookup(deny_maintenance_period.value, "time", null)
}
}
dynamic "ip_configuration" {
for_each = [local.ip_configurations[local.ip_configuration_enabled ? "enabled" : "disabled"]]
content {
Expand Down
10 changes: 10 additions & 0 deletions modules/mssql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ variable "maintenance_window_update_track" {
default = "canary"
}

variable "deny_maintenance_period" {
description = "The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/sqlserver/maintenance)"
type = list(object({
end_date = string
start_date = string
time = string
}))
default = []
}

variable "database_flags" {
description = "The database flags for the master instance. See [more details](https://cloud.google.com/sql/docs/sqlserver/flags)"
type = list(object({
Expand Down
4 changes: 2 additions & 2 deletions modules/mssql/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ terraform {

google = {
source = "hashicorp/google"
version = ">= 4.28.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.28.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
random = {
source = "hashicorp/random"
Expand Down
1 change: 1 addition & 0 deletions modules/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| db\_name | The name of the default database to create | `string` | `"default"` | no |
| delete\_timeout | The optional timout that is applied to limit long database deletes. | `string` | `"10m"` | no |
| deletion\_protection | Used to block Terraform from deleting a SQL Instance. | `bool` | `true` | no |
| deny\_maintenance\_period | The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance) | <pre>list(object({<br> end_date = string<br> start_date = string<br> time = string<br> }))</pre> | `[]` | no |
| disk\_autoresize | Configuration to increase storage size | `bool` | `true` | no |
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
| disk\_size | The disk size for the master instance | `number` | `10` | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ resource "google_sql_database_instance" "default" {
record_client_address = lookup(insights_config.value, "record_client_address", false)
}
}
dynamic "deny_maintenance_period" {
for_each = var.deny_maintenance_period
content {
end_date = lookup(deny_maintenance_period.value, "end_date", null)
start_date = lookup(deny_maintenance_period.value, "start_date", null)
time = lookup(deny_maintenance_period.value, "time", null)
}
}
dynamic "ip_configuration" {
for_each = [local.ip_configurations[local.ip_configuration_enabled ? "enabled" : "disabled"]]
content {
Expand Down
10 changes: 10 additions & 0 deletions modules/mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ variable "user_labels" {
description = "The key/value labels for the master instances."
}

variable "deny_maintenance_period" {
description = "The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance)"
type = list(object({
end_date = string
start_date = string
time = string
}))
default = []
}

variable "backup_configuration" {
description = "The backup_configuration settings subblock for the database setings"
type = object({
Expand Down
4 changes: 2 additions & 2 deletions modules/mysql/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ terraform {
}
google = {
source = "hashicorp/google"
version = ">= 4.28.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.4.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| db\_name | The name of the default database to create | `string` | `"default"` | no |
| delete\_timeout | The optional timout that is applied to limit long database deletes. | `string` | `"15m"` | no |
| deletion\_protection | Used to block Terraform from deleting a SQL Instance. | `bool` | `true` | no |
| deny\_maintenance\_period | The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/postgres/maintenance) | <pre>list(object({<br> end_date = string<br> start_date = string<br> time = string<br> }))</pre> | `[]` | no |
| disk\_autoresize | Configuration to increase storage size. | `bool` | `true` | no |
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
| disk\_size | The disk size for the master instance. | `number` | `10` | no |
Expand Down
8 changes: 8 additions & 0 deletions modules/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ resource "google_sql_database_instance" "default" {
}
}
}
dynamic "deny_maintenance_period" {
for_each = var.deny_maintenance_period
content {
end_date = lookup(deny_maintenance_period.value, "end_date", null)
start_date = lookup(deny_maintenance_period.value, "start_date", null)
time = lookup(deny_maintenance_period.value, "time", null)
}
}
dynamic "ip_configuration" {
for_each = [local.ip_configurations[local.ip_configuration_enabled ? "enabled" : "disabled"]]
content {
Expand Down
10 changes: 10 additions & 0 deletions modules/postgresql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ variable "user_labels" {
default = {}
}

variable "deny_maintenance_period" {
description = "The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/postgres/maintenance)"
type = list(object({
end_date = string
start_date = string
time = string
}))
default = []
}

variable "backup_configuration" {
description = "The backup_configuration settings subblock for the database setings"
type = object({
Expand Down
4 changes: 2 additions & 2 deletions modules/postgresql/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ terraform {
}
google = {
source = "hashicorp/google"
version = ">= 4.33.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.33.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/safer_mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ mysql -S $HOME/mysql_sockets/myproject:region:instance -u user -p
| db\_name | The name of the default database to create | `string` | `"default"` | no |
| delete\_timeout | The optional timout that is applied to limit long database deletes. | `string` | `"15m"` | no |
| deletion\_protection | Used to block Terraform from deleting a SQL Instance. | `bool` | `true` | no |
| deny\_maintenance\_period | The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance) | <pre>list(object({<br> end_date = string<br> start_date = string<br> time = string<br> }))</pre> | `[]` | no |
| disk\_autoresize | Configuration to increase storage size | `bool` | `true` | no |
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
| disk\_size | The disk size for the master instance | `number` | `10` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/safer_mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module "safer_mysql" {
maintenance_window_hour = var.maintenance_window_hour
maintenance_window_update_track = var.maintenance_window_update_track
database_flags = var.database_flags
deny_maintenance_period = var.deny_maintenance_period
encryption_key_name = var.encryption_key_name

deletion_protection = var.deletion_protection
Expand Down
10 changes: 10 additions & 0 deletions modules/safer_mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ variable "maintenance_window_update_track" {
default = "stable"
}

variable "deny_maintenance_period" {
description = "The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance)"
type = list(object({
end_date = string
start_date = string
time = string
}))
default = []
}

variable "database_flags" {
description = "The database flags for the master instance. See [more details](https://cloud.google.com/sql/docs/mysql/flags)"
type = list(object({
Expand Down
2 changes: 1 addition & 1 deletion modules/safer_mysql/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform {

google = {
source = "hashicorp/google"
version = ">= 4.28.0, < 5.0"
version = ">= 4.45.0, < 5.0"
}
}

Expand Down

0 comments on commit 55f4206

Please sign in to comment.