Skip to content

Commit 2021ae6

Browse files
committedFeb 28, 2024
Add maintenance window option to cloud sql
Signed-off-by: Matthias Kaemmer <m.kaemmer@sotec.eu>
1 parent 20aec1b commit 2021ae6

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed
 

‎terraform/infrastructure/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ No requirements.
3434
| <a name="input_enable_cert_manager"></a> [enable\_cert\_manager](#input\_enable\_cert\_manager) | Enables the service account needed for the use of cert manager | `bool` | `false` | no |
3535
| <a name="input_enable_http_ip_creation"></a> [enable\_http\_ip\_creation](#input\_enable\_http\_ip\_creation) | Used to enable the creation of a static ip for the http adapter | `string` | `false` | no |
3636
| <a name="input_enable_mqtt_ip_creation"></a> [enable\_mqtt\_ip\_creation](#input\_enable\_mqtt\_ip\_creation) | Used to enable the creation of a static ip for the mqtt adapter | `string` | `true` | no |
37-
| <a name="input_gke_cluster_maintenance_policy_recurring_window"></a> [gke\_cluster\_maintenance\_policy\_recurring\_window](#input\_gke\_cluster\_maintenance\_policy\_recurring\_window) | The recurring window maintenance policy for the cluster. For details see: https://registry.terraform.io/providers/hashicorp/google/5.15.0/docs/resources/container_cluster#nested_maintenance_policy | <pre>object({<br> start_time = string,<br> end_time = string,<br> recurrence = string<br> })</pre> | `null` | no |
37+
| <a name="input_gke_cluster_maintenance_policy_recurring_window"></a> [gke\_cluster\_maintenance\_policy\_recurring\_window](#input\_gke\_cluster\_maintenance\_policy\_recurring\_window) | The recurring window maintenance policy for the cluster. For details see: https://registry.terraform.io/providers/hashicorp/google/5.15.0/docs/resources/container_cluster#nested_maintenance_policy | <pre>object({<br> start_time = string,<br> end_time = string,<br> recurrence = string<br> })</pre> | `null` | no |
3838
| <a name="input_gke_cluster_name"></a> [gke\_cluster\_name](#input\_gke\_cluster\_name) | Name of the GKE Cluster | `string` | `"hono-cluster"` | no |
3939
| <a name="input_gke_machine_type"></a> [gke\_machine\_type](#input\_gke\_machine\_type) | Machine Type for node\_pools | `string` | `"c2-standard-8"` | no |
4040
| <a name="input_gke_node_pool_name"></a> [gke\_node\_pool\_name](#input\_gke\_node\_pool\_name) | The name of the Node Pool in the Hono Cluster | `string` | `"standard-node-pool"` | no |
@@ -71,6 +71,7 @@ No requirements.
7171
| <a name="input_sql_instance_disk_type"></a> [sql\_instance\_disk\_type](#input\_sql\_instance\_disk\_type) | Disk Type of the SQL Instance | `string` | `"PD-SSD"` | no |
7272
| <a name="input_sql_instance_ipv4_enable"></a> [sql\_instance\_ipv4\_enable](#input\_sql\_instance\_ipv4\_enable) | Whether this Cloud SQL instance should be assigned a public IPV4 address. At least ipv4\_enabled must be enabled or a private\_network must be configured. | `bool` | `false` | no |
7373
| <a name="input_sql_instance_machine_type"></a> [sql\_instance\_machine\_type](#input\_sql\_instance\_machine\_type) | Machine Type of the SQL Instance | `string` | `"db-custom-1-3840"` | no |
74+
| <a name="input_sql_instance_maintenance_window"></a> [sql\_instance\_maintenance\_window](#input\_sql\_instance\_maintenance\_window) | The maintenance window settings for the cloud sql instance. For details see: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance | <pre>object({<br> day = number,<br> hour = number,<br> update_track = optional(string, "stable")<br> })</pre> | `null` | no |
7475
| <a name="input_sql_instance_name"></a> [sql\_instance\_name](#input\_sql\_instance\_name) | Name of the SQL Instance | `string` | `"hono-sql"` | no |
7576
| <a name="input_sql_instance_version"></a> [sql\_instance\_version](#input\_sql\_instance\_version) | Database Version | `string` | `"POSTGRES_14"` | no |
7677
| <a name="input_ssl_policy_min_tls_version"></a> [ssl\_policy\_min\_tls\_version](#input\_ssl\_policy\_min\_tls\_version) | The minimum TLS version the SSL policy should allow | `string` | `"TLS_1_2"` | no |

‎terraform/infrastructure/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module "cloud_sql" {
4949
sql_instance_disk_type = var.sql_instance_disk_type
5050
sql_instance_deletion_protection_enabled = var.sql_instance_deletion_protection_enabled
5151
sql_instance_activation_policy = var.sql_instance_activation_policy
52+
sql_instance_maintenance_window = var.sql_instance_maintenance_window
5253
sql_public_ip_enable = var.sql_instance_ipv4_enable
5354
sql_db_user_name = var.sql_db_user_name
5455
sql_hono_database_name = var.sql_hono_database_name

‎terraform/infrastructure/variables.tf

+12-2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ variable "gke_cluster_name" {
5454
variable "gke_cluster_maintenance_policy_recurring_window" {
5555
type = object({
5656
start_time = string,
57-
end_time = string,
57+
end_time = string,
5858
recurrence = string
5959
})
6060
description = "The recurring window maintenance policy for the cluster. For details see: https://registry.terraform.io/providers/hashicorp/google/5.15.0/docs/resources/container_cluster#nested_maintenance_policy"
61-
default = null
61+
default = null
6262
}
6363

6464
variable "sql_instance_name" {
@@ -103,6 +103,16 @@ variable "sql_instance_ipv4_enable" {
103103
default = false
104104
}
105105

106+
variable "sql_instance_maintenance_window" {
107+
type = object({
108+
day = number,
109+
hour = number,
110+
update_track = optional(string, "stable")
111+
})
112+
description = "The maintenance window settings for the cloud sql instance. For details see: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance"
113+
default = null
114+
}
115+
106116
variable "sql_db_user_name" {
107117
type = string
108118
description = "The name of the user. Changing this forces a new resource to be created."

‎terraform/modules/cloud_sql/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ No modules.
4242
| <a name="input_sql_instance_deletion_protection_enabled"></a> [sql\_instance\_deletion\_protection\_enabled](#input\_sql\_instance\_deletion\_protection\_enabled) | Enables the deletion protection for the SQL instance. | `bool` | n/a | yes |
4343
| <a name="input_sql_instance_disk_type"></a> [sql\_instance\_disk\_type](#input\_sql\_instance\_disk\_type) | Disk Type of the SQL Instance | `string` | n/a | yes |
4444
| <a name="input_sql_instance_machine_type"></a> [sql\_instance\_machine\_type](#input\_sql\_instance\_machine\_type) | Machine Type of the SQL Instance | `string` | n/a | yes |
45+
| <a name="input_sql_instance_maintenance_window"></a> [sql\_instance\_maintenance\_window](#input\_sql\_instance\_maintenance\_window) | The maintenance window settings for the cloud sql instance. For details see: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance | <pre>object({<br> day = number,<br> hour = number,<br> update_track = string<br> })</pre> | n/a | yes |
4546
| <a name="input_sql_instance_name"></a> [sql\_instance\_name](#input\_sql\_instance\_name) | Name of the SQL Instance | `string` | n/a | yes |
4647
| <a name="input_sql_instance_version"></a> [sql\_instance\_version](#input\_sql\_instance\_version) | Database Version | `string` | n/a | yes |
4748
| <a name="input_sql_public_ip_enable"></a> [sql\_public\_ip\_enable](#input\_sql\_public\_ip\_enable) | Whether this Cloud SQL instance should be assigned a public IPV4 address. At least ipv4\_enabled must be enabled or a private\_network must be configured. | `bool` | n/a | yes |

‎terraform/modules/cloud_sql/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ resource "google_sql_database_instance" "hono_sql" {
1212
activation_policy = var.sql_instance_activation_policy
1313
deletion_protection_enabled = var.sql_instance_deletion_protection_enabled
1414

15+
dynamic "maintenance_window" {
16+
for_each = var.sql_instance_maintenance_window != null ? [1] : []
17+
content {
18+
day = var.sql_instance_maintenance_window.day
19+
hour = var.sql_instance_maintenance_window.hour
20+
update_track = var.sql_instance_maintenance_window.update_track
21+
}
22+
}
23+
1524
ip_configuration {
1625
ipv4_enabled = var.sql_public_ip_enable
1726
private_network = var.network_id

‎terraform/modules/cloud_sql/variables.tf

+10-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,13 @@ variable "sql_instance_backup_start_time" {
8989
variable "sql_instance_backup_count" {
9090
type = number
9191
description = "The number of backups the Cloud SQL instance should retain."
92-
}
92+
}
93+
94+
variable "sql_instance_maintenance_window" {
95+
type = object({
96+
day = number,
97+
hour = number,
98+
update_track = string
99+
})
100+
description = "The maintenance window settings for the cloud sql instance. For details see: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance"
101+
}

0 commit comments

Comments
 (0)