Skip to content

Commit

Permalink
fix: Correct random password lifecycle by eagerly creating random pas…
Browse files Browse the repository at this point in the history
…sword value (#388)
  • Loading branch information
bryantbiggs committed Feb 23, 2022
1 parent 8ede33d commit b41a0a5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
create_random_password = var.create_db_instance && var.create_random_password && var.replicate_source_db == null
password = try(random_password.master_password[0].result, var.password)
create_random_password = var.create_db_instance && var.create_random_password
password = local.create_random_password ? random_password.master_password[0].result : var.password

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

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

length = var.random_password_length
Expand Down

0 comments on commit b41a0a5

Please sign in to comment.