Skip to content

Commit f96f71e

Browse files
authored
fix!: Change additional user default password (#332)
* Change additional_users default password * Update unit test with sensitive values * Add upgrade section to docs * Fix example sensitive output * Update docs/upgrading_to_sql_db_12.0.0.md
1 parent ad6f427 commit f96f71e

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

docs/upgrading_to_sql_db_12.0.0.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,19 @@ module "pg" {
9595
]
9696
}
9797
```
98+
99+
Prior to the 12.0.0 `mysql` module release, additional users were created using the `default_user`'s password. In order to keep the password unchanged for additional users for release 12.0.0 and up, `additional_user`'s passwords need to be set explicitly using the `default_user`'s generated password.
100+
101+
```diff
102+
module "mysql" {
103+
source = "GoogleCloudPlatform/sql-db/google//modules/mysql"
104+
- version = "~> 11.0"
105+
+ version = "~> 12.0"
106+
107+
project_id = var.project_id
108+
additional_users = [{
109+
name = "admin"
110+
+ password = module.mysql.generated_user_password
111+
}]
112+
}
113+
```

examples/mysql-private/outputs.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ output "mysql_conn" {
3030
}
3131

3232
output "mysql_user_pass" {
33+
sensitive = true
3334
value = module.safer-mysql-db.generated_user_password
3435
description = "The password for the default user. If not set, a random one will be generated and available in the generated_user_password output variable."
3536
}

examples/mysql-public/outputs.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ output "mysql_conn" {
3030
}
3131

3232
output "mysql_user_pass" {
33+
sensitive = true
3334
value = module.mysql-db.generated_user_password
3435
description = "The password for the default user. If not set, a random one will be generated and available in the generated_user_password output variable."
3536
}

modules/mysql/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ resource "google_sql_user" "additional_users" {
192192
for_each = local.users
193193
project = var.project_id
194194
name = each.value.name
195-
password = lookup(each.value, "password", random_password.user-password.result)
195+
password = lookup(each.value, "password", random_password.additional_passwords[each.key].result)
196196
host = lookup(each.value, "host", var.user_host)
197197
instance = google_sql_database_instance.default.name
198198
type = lookup(each.value, "type", "BUILT_IN")

0 commit comments

Comments
 (0)