Skip to content

Commit

Permalink
feat: Add deletion_protection variable, defaulted to true (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
jle35 committed Oct 23, 2020
1 parent 3e26f5a commit 69e1911
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/mssql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The following dependency must be available for SQL Server module:
| db\_collation | The collation for the default database. Example: 'en_US.UTF8' | string | `""` | no |
| 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 | `"30m"` | no |
| deletion\_protection | Used to block Terraform from deleting a SQL Instance. | bool | `"true"` | no |
| disk\_autoresize | Configuration to increase storage size. | bool | `"true"` | no |
| disk\_size | The disk size for the master instance. | string | `"10"` | no |
| disk\_type | The disk type for the master instance. | string | `"PD_SSD"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/mssql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ resource "google_sql_database_instance" "default" {
region = var.region
encryption_key_name = var.encryption_key_name
root_password = coalesce(var.root_password, random_password.root-password.result)
deletion_protection = var.deletion_protection

settings {
tier = var.tier
Expand Down
6 changes: 6 additions & 0 deletions modules/mssql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,9 @@ variable "encryption_key_name" {
type = string
default = null
}

variable "deletion_protection" {
description = "Used to block Terraform from deleting a SQL Instance."
type = bool
default = true
}
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\_collation | The collation for the default database. Example: 'utf8_general_ci' | string | `""` | no |
| 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 |
| disk\_autoresize | Configuration to increase storage size | bool | `"true"` | no |
| disk\_size | The disk size for the master instance | number | `"10"` | no |
| disk\_type | The disk type for the master instance. | string | `"PD_SSD"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ resource "google_sql_database_instance" "default" {
database_version = var.database_version
region = var.region
encryption_key_name = var.encryption_key_name
deletion_protection = var.deletion_protection

settings {
tier = var.tier
Expand Down
6 changes: 6 additions & 0 deletions modules/mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,9 @@ variable "module_depends_on" {
type = list(any)
default = []
}

variable "deletion_protection" {
description = "Used to block Terraform from deleting a SQL Instance."
type = bool
default = true
}
1 change: 1 addition & 0 deletions modules/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| db\_collation | The collation for the default database. Example: 'en_US.UTF8' | string | `""` | no |
| 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 |
| disk\_autoresize | Configuration to increase storage size. | bool | `"true"` | no |
| disk\_size | The disk size for the master instance. | string | `"10"` | no |
| disk\_type | The disk type for the master instance. | string | `"PD_SSD"` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ resource "google_sql_database_instance" "default" {
database_version = var.database_version
region = var.region
encryption_key_name = var.encryption_key_name
deletion_protection = var.deletion_protection

settings {
tier = var.tier
Expand Down
5 changes: 5 additions & 0 deletions modules/postgresql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,8 @@ variable "module_depends_on" {
default = []
}

variable "deletion_protection" {
description = "Used to block Terraform from deleting a SQL Instance."
type = bool
default = true
}

0 comments on commit 69e1911

Please sign in to comment.