Skip to content

Commit

Permalink
feat!: adds settings.deletion_protection_enabled to modules (#404)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Peabody <andrewpeabody@google.com>
  • Loading branch information
KelvinVenancio and apeabody committed Jan 14, 2023
1 parent 7d6b209 commit af48cd3
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 16 deletions.
1 change: 1 addition & 0 deletions modules/mssql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| deletion\_protection\_enabled | Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | 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 |
Expand Down
7 changes: 4 additions & 3 deletions modules/mssql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ resource "google_sql_database_instance" "default" {
deletion_protection = var.deletion_protection

settings {
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
deletion_protection_enabled = var.deletion_protection_enabled
dynamic "backup_configuration" {
for_each = var.backup_configuration.enabled ? [var.backup_configuration] : []
content {
Expand Down
6 changes: 6 additions & 0 deletions modules/mssql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ variable "availability_type" {
default = "ZONAL"
}

variable "deletion_protection_enabled" {
description = "Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform)."
type = bool
default = false
}

variable "disk_autoresize" {
description = "Configuration to increase storage size."
type = bool
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.45.0, < 5.0"
version = ">= 4.48.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.45.0, < 5.0"
version = ">= 4.48.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 |
| deletion\_protection\_enabled | Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | 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 |
Expand Down
7 changes: 4 additions & 3 deletions modules/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ resource "google_sql_database_instance" "default" {
deletion_protection = var.deletion_protection

settings {
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
deletion_protection_enabled = var.deletion_protection_enabled
dynamic "backup_configuration" {
for_each = [var.backup_configuration]
content {
Expand Down
6 changes: 6 additions & 0 deletions modules/mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ variable "availability_type" {
default = "REGIONAL"
}

variable "deletion_protection_enabled" {
description = "Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform)."
type = bool
default = false
}

variable "disk_autoresize" {
description = "Configuration to increase storage size"
type = bool
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.45.0, < 5.0"
version = ">= 4.48.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.45.0, < 5.0"
version = ">= 4.48.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 |
| deletion\_protection\_enabled | Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | 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 |
Expand Down
7 changes: 4 additions & 3 deletions modules/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ resource "google_sql_database_instance" "default" {
deletion_protection = var.deletion_protection

settings {
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
deletion_protection_enabled = var.deletion_protection_enabled

dynamic "backup_configuration" {
for_each = [var.backup_configuration]
Expand Down
6 changes: 6 additions & 0 deletions modules/postgresql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ variable "availability_type" {
default = "ZONAL"
}

variable "deletion_protection_enabled" {
description = "Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform)."
type = bool
default = false
}

variable "disk_autoresize" {
description = "Configuration to increase storage size."
type = bool
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.45.0, < 5.0"
version = ">= 4.48.0, < 5.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = ">= 4.45.0, < 5.0"
version = ">= 4.48.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 |
| deletion\_protection\_enabled | Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | 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 |
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 @@ -27,6 +27,7 @@ module "safer_mysql" {
tier = var.tier
activation_policy = var.activation_policy
availability_type = var.availability_type
deletion_protection_enabled = var.deletion_protection_enabled
disk_autoresize = var.disk_autoresize
disk_autoresize_limit = var.disk_autoresize_limit
disk_size = var.disk_size
Expand Down
6 changes: 6 additions & 0 deletions modules/safer_mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ variable "availability_type" {
default = "REGIONAL"
}

variable "deletion_protection_enabled" {
description = "Enables protection of an instance from accidental deletion protection across all surfaces (API, gcloud, Cloud Console and Terraform)."
type = bool
default = false
}

variable "disk_autoresize" {
description = "Configuration to increase storage size"
type = bool
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.45.0, < 5.0"
version = ">= 4.48.0, < 5.0"
}
}

Expand Down

0 comments on commit af48cd3

Please sign in to comment.