Skip to content

Commit b41a0a5

Browse files
authored
fix: Correct random password lifecycle by eagerly creating random password value (#388)
1 parent 8ede33d commit b41a0a5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
2-
create_random_password = var.create_db_instance && var.create_random_password && var.replicate_source_db == null
3-
password = try(random_password.master_password[0].result, var.password)
2+
create_random_password = var.create_db_instance && var.create_random_password
3+
password = local.create_random_password ? random_password.master_password[0].result : var.password
44

55
db_subnet_group_name = var.create_db_subnet_group ? module.db_subnet_group.db_subnet_group_id : var.db_subnet_group_name
66
parameter_group_name_id = var.create_db_parameter_group ? module.db_parameter_group.db_parameter_group_id : var.parameter_group_name
@@ -10,7 +10,6 @@ locals {
1010
}
1111

1212
resource "random_password" "master_password" {
13-
# We don't need to create a random password for instances that are replicas or restored from a snapshot
1413
count = local.create_random_password ? 1 : 0
1514

1615
length = var.random_password_length

0 commit comments

Comments
 (0)