Skip to content

Commit

Permalink
fix(mongodb): Resolve undetermined count issue in random_password (#84)
Browse files Browse the repository at this point in the history
* fix(mongodb): Resolve undetermined count issue in random_password

* fix(mongodb): Refactor the password with try block
  • Loading branch information
akhil-redacre authored Sep 9, 2024
1 parent 8d214e5 commit d6a4688
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mongodbatlas/user/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data "mongodbatlas_cluster" "this" {
resource "mongodbatlas_database_user" "user" {
provider = mongodbatlas.creds
username = var.external_username != null ? var.external_username : lower("${var.platform}-${var.brandname}${var.name_suffix}")
password = var.external_password != null ? var.external_password : random_password.password[0].result
password = try(var.external_password, random_password.password.result)
project_id = var.mongodb_projectid
auth_database_name = "admin"

Expand All @@ -32,7 +32,7 @@ resource "mongodbatlas_database_user" "user" {
}

resource "random_password" "password" {
count = var.external_password != null ? 0 : 1 # Use the password based on the condition

length = 24
special = false
}
Expand Down

0 comments on commit d6a4688

Please sign in to comment.