Skip to content

Commit 1c9ce24

Browse files
authored
fix: make special chars opt in for generated passwords (#421)
1 parent b3e7db6 commit 1c9ce24

File tree

7 files changed

+19
-4
lines changed

7 files changed

+19
-4
lines changed

examples/postgresql-public-iam/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module "postgresql-db" {
4444
password_change_interval = "3600s"
4545
reuse_interval = 1
4646
}
47+
enable_random_password_special = true
4748

4849
database_flags = [
4950
{

modules/mysql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
2828
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
2929
| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no |
3030
| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no |
31+
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |
3132
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
3233
| 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 |
3334
| 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 |

modules/mysql/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ resource "random_password" "user-password" {
189189
}
190190

191191
length = 32
192-
special = true
192+
special = var.enable_random_password_special
193193
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
194194
}
195195

@@ -199,7 +199,7 @@ resource "random_password" "additional_passwords" {
199199
name = google_sql_database_instance.default.name
200200
}
201201
length = 32
202-
special = true
202+
special = var.enable_random_password_special
203203
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
204204
}
205205

modules/mysql/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,9 @@ variable "enable_default_user" {
383383
type = bool
384384
default = true
385385
}
386+
387+
variable "enable_random_password_special" {
388+
description = "Enable special characters in generated random passwords."
389+
type = bool
390+
default = false
391+
}

modules/postgresql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
2929
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
3030
| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no |
3131
| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no |
32+
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |
3233
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
3334
| 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 |
3435
| iam\_user\_emails | A list of IAM users to be created in your cluster | `list(string)` | `[]` | no |

modules/postgresql/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ resource "random_password" "user-password" {
199199
}
200200

201201
length = 32
202-
special = true
202+
special = var.enable_random_password_special
203203
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
204204
}
205205

@@ -209,7 +209,7 @@ resource "random_password" "additional_passwords" {
209209
name = google_sql_database_instance.default.name
210210
}
211211
length = 32
212-
special = true
212+
special = var.enable_random_password_special
213213
depends_on = [null_resource.module_depends_on, google_sql_database_instance.default]
214214
}
215215

modules/postgresql/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,9 @@ variable "user_deletion_policy" {
385385
type = string
386386
default = null
387387
}
388+
389+
variable "enable_random_password_special" {
390+
description = "Enable special characters in generated random passwords."
391+
type = bool
392+
default = false
393+
}

0 commit comments

Comments
 (0)