Skip to content

Commit

Permalink
feat: add support for query_plans_per_minute (#484)
Browse files Browse the repository at this point in the history
Co-authored-by: Awais Malik <malik.awais@gmail.com>
Co-authored-by: Awais Malik <awmalik@google.com>
  • Loading branch information
3 people committed Aug 23, 2023
1 parent b193e1c commit ffb674c
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/mysql/README.md
Expand Up @@ -35,7 +35,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
| follow\_gae\_application | A Google App Engine application whose zone to remain in. Must be in the same region as this instance. | `string` | `null` | no |
| iam\_users | A list of IAM users to be created in your CloudSQL instance | <pre>list(object({<br> id = string,<br> email = string<br> }))</pre> | `[]` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
| ip\_configuration | The ip\_configuration settings subblock | <pre>object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> enable_private_path_for_google_cloud_services = optional(bool)<br> })</pre> | <pre>{<br> "allocated_ip_range": null,<br> "authorized_networks": [],<br> "enable_private_path_for_google_cloud_services": false,<br> "ipv4_enabled": true,<br> "private_network": null,<br> "require_ssl": null<br>}</pre> | no |
| maintenance\_window\_day | The day of week (1-7) for the master instance maintenance. | `number` | `1` | no |
| maintenance\_window\_hour | The hour of day (0-23) maintenance window for the master instance maintenance. | `number` | `23` | no |
Expand All @@ -49,7 +49,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| read\_replica\_deletion\_protection | Used to block Terraform from deleting replica SQL Instances. | `bool` | `false` | no |
| read\_replica\_deletion\_protection\_enabled | Enables protection of a read replica from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | no |
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
| read\_replicas | List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption\_key\_name = null | <pre>list(object({<br> name = string<br> name_override = optional(string)<br> tier = string<br> edition = optional(string)<br> zone = string<br> availability_type = string<br> disk_type = string<br> disk_autoresize = bool<br> disk_autoresize_limit = number<br> disk_size = string<br> user_labels = map(string)<br> database_flags = list(object({<br> name = string<br> value = string<br> }))<br> insights_config = optional(object({<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> }))<br> ip_configuration = object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> enable_private_path_for_google_cloud_services = optional(bool)<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
| read\_replicas | List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption\_key\_name = null | <pre>list(object({<br> name = string<br> name_override = optional(string)<br> tier = string<br> edition = optional(string)<br> zone = string<br> availability_type = string<br> disk_type = string<br> disk_autoresize = bool<br> disk_autoresize_limit = number<br> disk_size = string<br> user_labels = map(string)<br> database_flags = list(object({<br> name = string<br> value = string<br> }))<br> insights_config = optional(object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> }))<br> ip_configuration = object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> enable_private_path_for_google_cloud_services = optional(bool)<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
| region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no |
| replica\_database\_version | The read replica database version to use. This var should only be used during a database update. The update sequence 1. read-replica 2. master, setting this to an updated version will cause the replica to update, then you may update the master with the var database\_version and remove this field after update is complete | `string` | `""` | no |
| root\_password | Mysql password for the root user. If not set, a random one will be generated and available in the root\_password output variable. | `string` | `""` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/mysql/main.tf
Expand Up @@ -90,6 +90,7 @@ resource "google_sql_database_instance" "default" {

content {
query_insights_enabled = true
query_plans_per_minute = lookup(insights_config.value, "query_plans_per_minute", 5)
query_string_length = lookup(insights_config.value, "query_string_length", 1024)
record_application_tags = lookup(insights_config.value, "record_application_tags", false)
record_client_address = lookup(insights_config.value, "record_client_address", false)
Expand Down
1 change: 1 addition & 0 deletions modules/mysql/metadata.yaml
Expand Up @@ -187,6 +187,7 @@ spec:
description: The insights_config settings for the database.
type: |-
object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down
2 changes: 1 addition & 1 deletion modules/mysql/read_replica.tf
Expand Up @@ -48,6 +48,7 @@ resource "google_sql_database_instance" "replicas" {

content {
query_insights_enabled = true
query_plans_per_minute = lookup(insights_config.value, "query_plans_per_minute", 5)
query_string_length = lookup(insights_config.value, "query_string_length", 1024)
record_application_tags = lookup(insights_config.value, "record_application_tags", false)
record_client_address = lookup(insights_config.value, "record_client_address", false)
Expand Down Expand Up @@ -110,4 +111,3 @@ resource "google_sql_database_instance" "replicas" {
delete = var.delete_timeout
}
}

2 changes: 2 additions & 0 deletions modules/mysql/variables.tf
Expand Up @@ -208,6 +208,7 @@ variable "backup_configuration" {
variable "insights_config" {
description = "The insights_config settings for the database."
type = object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down Expand Up @@ -266,6 +267,7 @@ variable "read_replicas" {
value = string
}))
insights_config = optional(object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down
2 changes: 1 addition & 1 deletion modules/postgresql/README.md
Expand Up @@ -35,7 +35,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
| follow\_gae\_application | A Google App Engine application whose zone to remain in. Must be in the same region as this instance. | `string` | `null` | no |
| iam\_users | A list of IAM users to be created in your CloudSQL instance | <pre>list(object({<br> id = string,<br> email = string<br> }))</pre> | `[]` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
| ip\_configuration | The ip configuration for the master instances. | <pre>object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> enable_private_path_for_google_cloud_services = optional(bool)<br> })</pre> | <pre>{<br> "allocated_ip_range": null,<br> "authorized_networks": [],<br> "enable_private_path_for_google_cloud_services": false,<br> "ipv4_enabled": true,<br> "private_network": null,<br> "require_ssl": null<br>}</pre> | no |
| maintenance\_window\_day | The day of week (1-7) for the master instance maintenance. | `number` | `1` | no |
| maintenance\_window\_hour | The hour of day (0-23) maintenance window for the master instance maintenance. | `number` | `23` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/postgresql/main.tf
Expand Up @@ -117,6 +117,7 @@ resource "google_sql_database_instance" "default" {

content {
query_insights_enabled = true
query_plans_per_minute = lookup(insights_config.value, "query_plans_per_minute", 5)
query_string_length = lookup(insights_config.value, "query_string_length", 1024)
record_application_tags = lookup(insights_config.value, "record_application_tags", false)
record_client_address = lookup(insights_config.value, "record_client_address", false)
Expand Down
1 change: 1 addition & 0 deletions modules/postgresql/metadata.yaml
Expand Up @@ -192,6 +192,7 @@ spec:
description: The insights_config settings for the database.
type: |-
object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down
2 changes: 1 addition & 1 deletion modules/postgresql/read_replica.tf
Expand Up @@ -66,6 +66,7 @@ resource "google_sql_database_instance" "replicas" {

content {
query_insights_enabled = true
query_plans_per_minute = lookup(insights_config.value, "query_plans_per_minute", 5)
query_string_length = lookup(insights_config.value, "query_string_length", 1024)
record_application_tags = lookup(insights_config.value, "record_application_tags", false)
record_client_address = lookup(insights_config.value, "record_client_address", false)
Expand Down Expand Up @@ -108,4 +109,3 @@ resource "google_sql_database_instance" "replicas" {
delete = var.delete_timeout
}
}

1 change: 1 addition & 0 deletions modules/postgresql/variables.tf
Expand Up @@ -199,6 +199,7 @@ variable "backup_configuration" {
variable "insights_config" {
description = "The insights_config settings for the database."
type = object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down
4 changes: 2 additions & 2 deletions modules/safer_mysql/README.md
Expand Up @@ -190,7 +190,7 @@ mysql -S $HOME/mysql_sockets/myproject:region:instance -u user -p
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
| follow\_gae\_application | A Google App Engine application whose zone to remain in. Must be in the same region as this instance. | `string` | `null` | no |
| iam\_users | A list of IAM users to be created in your CloudSQL instance | <pre>list(object({<br> id = string,<br> email = string<br> }))</pre> | `[]` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
| maintenance\_window\_day | The day of week (1-7) for the master instance maintenance. | `number` | `1` | no |
| maintenance\_window\_hour | The hour of day (0-23) maintenance window for the master instance maintenance. | `number` | `23` | no |
| maintenance\_window\_update\_track | The update track of maintenance window for the master instance maintenance. Can be either `canary` or `stable`. | `string` | `"stable"` | no |
Expand All @@ -202,7 +202,7 @@ mysql -S $HOME/mysql_sockets/myproject:region:instance -u user -p
| read\_replica\_deletion\_protection | Used to block Terraform from deleting replica SQL Instances. | `bool` | `false` | no |
| read\_replica\_deletion\_protection\_enabled | Enables protection of a read replica from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | no |
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
| read\_replicas | List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption\_key\_name = null | <pre>list(object({<br> name = string<br> name_override = optional(string)<br> tier = string<br> edition = string<br> availability_type = string<br> zone = string<br> disk_type = string<br> disk_autoresize = bool<br> disk_autoresize_limit = number<br> disk_size = string<br> user_labels = map(string)<br> database_flags = list(object({<br> name = string<br> value = string<br> }))<br> insights_config = optional(object({<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> }))<br> ip_configuration = object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
| read\_replicas | List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption\_key\_name = null | <pre>list(object({<br> name = string<br> name_override = optional(string)<br> tier = string<br> edition = string<br> availability_type = string<br> zone = string<br> disk_type = string<br> disk_autoresize = bool<br> disk_autoresize_limit = number<br> disk_size = string<br> user_labels = map(string)<br> database_flags = list(object({<br> name = string<br> value = string<br> }))<br> insights_config = optional(object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> }))<br> ip_configuration = object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
| region | The region of the Cloud SQL resources | `string` | n/a | yes |
| secondary\_zone | The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no |
| tier | The tier for the master instance. | `string` | `"db-n1-standard-1"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/safer_mysql/metadata.yaml
Expand Up @@ -178,6 +178,7 @@ spec:
description: The insights_config settings for the database.
type: |-
object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down
2 changes: 2 additions & 0 deletions modules/safer_mysql/variables.tf
Expand Up @@ -241,6 +241,7 @@ variable "read_replicas" {
value = string
}))
insights_config = optional(object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down Expand Up @@ -363,6 +364,7 @@ variable "encryption_key_name" {
variable "insights_config" {
description = "The insights_config settings for the database."
type = object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
Expand Down

0 comments on commit ffb674c

Please sign in to comment.