Skip to content

Commit

Permalink
fix: make special chars opt in for generated passwords (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathkkb committed Feb 10, 2023
1 parent b3e7db6 commit 1c9ce24
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/postgresql-public-iam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "postgresql-db" {
password_change_interval = "3600s"
reuse_interval = 1
}
enable_random_password_special = true

database_flags = [
{
Expand Down
1 change: 1 addition & 0 deletions modules/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
| 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 |
| 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 |
| 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 |
| 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 |
Expand Down
4 changes: 2 additions & 2 deletions modules/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ resource "random_password" "user-password" {
}

length = 32
special = true
special = var.enable_random_password_special
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
}

Expand All @@ -199,7 +199,7 @@ resource "random_password" "additional_passwords" {
name = google_sql_database_instance.default.name
}
length = 32
special = true
special = var.enable_random_password_special
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
}

Expand Down
6 changes: 6 additions & 0 deletions modules/mysql/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,9 @@ variable "enable_default_user" {
type = bool
default = true
}

variable "enable_random_password_special" {
description = "Enable special characters in generated random passwords."
type = bool
default = false
}
1 change: 1 addition & 0 deletions modules/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
| 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 |
| 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 |
| 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\_user\_emails | A list of IAM users to be created in your cluster | `list(string)` | `[]` | no |
Expand Down
4 changes: 2 additions & 2 deletions modules/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ resource "random_password" "user-password" {
}

length = 32
special = true
special = var.enable_random_password_special
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
}

Expand All @@ -209,7 +209,7 @@ resource "random_password" "additional_passwords" {
name = google_sql_database_instance.default.name
}
length = 32
special = true
special = var.enable_random_password_special
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
}

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

variable "enable_random_password_special" {
description = "Enable special characters in generated random passwords."
type = bool
default = false
}

0 comments on commit 1c9ce24

Please sign in to comment.