Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/upgrading_to_sql_db_26.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Upgrading to v26.0

The v26.0 release contains backwards-incompatible changes.

This update requires upgrading the minimum provider version from `6.1` to `6.17`
1 change: 1 addition & 0 deletions modules/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module "mysql-db" {
| enable\_google\_ml\_integration | Enable database ML integration | `bool` | `false` | no |
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
| failover\_dr\_replica\_name | If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format. | `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. iam.users.type can be CLOUD\_IAM\_USER, CLOUD\_IAM\_SERVICE\_ACCOUNT, CLOUD\_IAM\_GROUP and is required for type CLOUD\_IAM\_GROUP (IAM groups) | <pre>list(object({<br> id = string,<br> email = string,<br> type = optional(string)<br> }))</pre> | `[]` | 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 |
Expand Down
7 changes: 7 additions & 0 deletions modules/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ resource "google_sql_database_instance" "default" {
deletion_protection = var.deletion_protection
root_password = var.root_password == "" ? null : var.root_password

dynamic "replication_cluster" {
for_each = var.failover_dr_replica_name != null ? [var.failover_dr_replica_name] : []
content {
failover_dr_replica_name = var.failover_dr_replica_name
}
}

settings {
tier = var.tier
edition = var.edition
Expand Down
3 changes: 3 additions & 0 deletions modules/mysql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ spec:
- name: master_instance_name
description: The name of the existing instance that will act as the master in the replication setup.
varType: string
- name: failover_dr_replica_name
description: If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format.
varType: string
- name: instance_type
description: Users can upgrade a read replica instance to a stand-alone Cloud SQL instance with the help of instance_type. To promote, users have to set the instance_type property as CLOUD_SQL_INSTANCE and remove/unset master_instance_name and replica_configuration from instance configuration. This operation might cause your instance to restart.
varType: string
Expand Down
7 changes: 7 additions & 0 deletions modules/mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ variable "master_instance_name" {
default = null
}

//optional
variable "failover_dr_replica_name" {
type = string
description = "If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is \"your-project:your-instance\". You can also set this field to \"your-instance\", but cloud SQL backend will convert it to the aforementioned standard format."
default = null
}

// optional
variable "instance_type" {
description = "Users can upgrade a read replica instance to a stand-alone Cloud SQL instance with the help of instance_type. To promote, users have to set the instance_type property as CLOUD_SQL_INSTANCE and remove/unset master_instance_name and replica_configuration from instance configuration. This operation might cause your instance to restart."
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 = ">= 6.1, < 7"
version = ">= 6.17, < 7"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 6.1, < 7"
version = ">= 6.17, < 7"
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ module "pg" {
| enable\_google\_ml\_integration | Enable database ML integration | `bool` | `false` | no |
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
| failover\_dr\_replica\_name | If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format. | `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. iam.users.type can be CLOUD\_IAM\_USER, CLOUD\_IAM\_SERVICE\_ACCOUNT, CLOUD\_IAM\_GROUP and is required for type CLOUD\_IAM\_GROUP (IAM groups) | <pre>list(object({<br> id = string,<br> email = string,<br> type = optional(string)<br> }))</pre> | `[]` | no |
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_plans_per_minute = optional(number, 5)<br> query_string_length = optional(number, 1024)<br> record_application_tags = optional(bool, false)<br> record_client_address = optional(bool, false)<br> })</pre> | `null` | no |
Expand Down
7 changes: 7 additions & 0 deletions modules/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ resource "google_sql_database_instance" "default" {
master_instance_name = var.master_instance_name
instance_type = local.is_secondary_instance ? "READ_REPLICA_INSTANCE" : var.instance_type

dynamic "replication_cluster" {
for_each = var.failover_dr_replica_name != null ? [var.failover_dr_replica_name] : []
content {
failover_dr_replica_name = var.failover_dr_replica_name
}
}

settings {
tier = var.tier
edition = var.edition
Expand Down
3 changes: 3 additions & 0 deletions modules/postgresql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ spec:
- name: master_instance_name
description: Name of the master instance if this is a failover replica. Required for creating failover replica instance. Not needed for master instance. When removed, next terraform apply will promote this failover failover replica instance as master instance
varType: string
- name: failover_dr_replica_name
description: If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format.
varType: string
- name: instance_type
description: The type of the instance. The supported values are SQL_INSTANCE_TYPE_UNSPECIFIED, CLOUD_SQL_INSTANCE, ON_PREMISES_INSTANCE and READ_REPLICA_INSTANCE. Set to READ_REPLICA_INSTANCE if master_instance_name value is provided
varType: string
Expand Down
6 changes: 6 additions & 0 deletions modules/postgresql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ variable "master_instance_name" {
default = null
}

variable "failover_dr_replica_name" {
type = string
description = "If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is \"your-project:your-instance\". You can also set this field to \"your-instance\", but cloud SQL backend will convert it to the aforementioned standard format."
default = null
}

variable "instance_type" {
type = string
description = "The type of the instance. The supported values are SQL_INSTANCE_TYPE_UNSPECIFIED, CLOUD_SQL_INSTANCE, ON_PREMISES_INSTANCE and READ_REPLICA_INSTANCE. Set to READ_REPLICA_INSTANCE if master_instance_name value is provided"
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 = ">= 6.1, < 7"
version = ">= 6.17, < 7"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 6.1, < 7"
version = ">= 6.17, < 7"
}
}

Expand Down
3 changes: 3 additions & 0 deletions modules/safer_mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,16 @@ module "safer-mysql-db" {
| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no |
| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no |
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
| failover\_dr\_replica\_name | If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format. | `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. iam.users.type can be CLOUD\_IAM\_USER, CLOUD\_IAM\_SERVICE\_ACCOUNT, CLOUD\_IAM\_GROUP and is required for type CLOUD\_IAM\_GROUP (IAM groups) | <pre>list(object({<br> id = string,<br> email = string,<br> type = optional(string)<br> }))</pre> | `[]` | 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 |
| instance\_type | Users can upgrade a read replica instance to a stand-alone Cloud SQL instance with the help of instance\_type. To promote, users have to set the instance\_type property as CLOUD\_SQL\_INSTANCE and remove/unset master\_instance\_name and replica\_configuration from instance configuration. This operation might cause your instance to restart. | `string` | `null` | no |
| maintenance\_version | The current software version on the instance. This attribute can not be set during creation. Refer to available\_maintenance\_versions attribute to see what maintenance\_version are available for upgrade. When this attribute gets updated, it will cause an instance restart. Setting a maintenance\_version value that is older than the current one on the instance will be ignored | `string` | `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 |
| master\_instance\_name | The name of the existing instance that will act as the master in the replication setup. | `string` | `null` | no |
| module\_depends\_on | List of modules or resources this module depends on. | `list(any)` | `[]` | no |
| name | The name of the Cloud SQL resources | `string` | n/a | yes |
| pricing\_plan | The pricing plan for the master instance. | `string` | `"PER_USE"` | no |
Expand Down
3 changes: 3 additions & 0 deletions modules/safer_mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ module "safer_mysql" {
region = var.region
zone = var.zone
secondary_zone = var.secondary_zone
master_instance_name = var.master_instance_name
failover_dr_replica_name = var.failover_dr_replica_name
instance_type = var.instance_type
follow_gae_application = var.follow_gae_application
tier = var.tier
edition = var.edition
Expand Down
9 changes: 9 additions & 0 deletions modules/safer_mysql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ spec:
- name: encryption_key_name
description: The full path to the encryption key used for the CMEK disk encryption
varType: string
- name: failover_dr_replica_name
description: If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format.
varType: string
- name: follow_gae_application
description: A Google App Engine application whose zone to remain in. Must be in the same region as this instance.
varType: string
Expand All @@ -212,6 +215,9 @@ spec:
record_application_tags = bool
record_client_address = bool
})
- name: instance_type
description: Users can upgrade a read replica instance to a stand-alone Cloud SQL instance with the help of instance_type. To promote, users have to set the instance_type property as CLOUD_SQL_INSTANCE and remove/unset master_instance_name and replica_configuration from instance configuration. This operation might cause your instance to restart.
varType: string
- name: maintenance_window_day
description: The day of week (1-7) for the master instance maintenance.
varType: number
Expand All @@ -224,6 +230,9 @@ spec:
description: The update track of maintenance window for the master instance maintenance. Can be either `canary` or `stable`.
varType: string
defaultValue: stable
- name: master_instance_name
description: The name of the existing instance that will act as the master in the replication setup.
varType: string
- name: module_depends_on
description: List of modules or resources this module depends on.
varType: list(any)
Expand Down
21 changes: 21 additions & 0 deletions modules/safer_mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ variable "secondary_zone" {
default = null
}

// optional
variable "master_instance_name" {
description = "The name of the existing instance that will act as the master in the replication setup."
type = string
default = null
}

//optional
variable "failover_dr_replica_name" {
type = string
description = "If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is \"your-project:your-instance\". You can also set this field to \"your-instance\", but cloud SQL backend will convert it to the aforementioned standard format."
default = null
}

// optional
variable "instance_type" {
description = "Users can upgrade a read replica instance to a stand-alone Cloud SQL instance with the help of instance_type. To promote, users have to set the instance_type property as CLOUD_SQL_INSTANCE and remove/unset master_instance_name and replica_configuration from instance configuration. This operation might cause your instance to restart."
type = string
default = null
}

variable "follow_gae_application" {
type = string
description = "A Google App Engine application whose zone to remain in. Must be in the same region as this instance."
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 = ">= 6.1, < 7"
version = ">= 6.17, < 7"
}
}

Expand Down