Skip to content

Commit d717b1d

Browse files
authored
Merge branch 'main' into backup-encryption
2 parents 592308e + ee3fb7b commit d717b1d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

solutions/standard/main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@ resource "random_password" "admin_password" {
235235
min_numeric = 1
236236
}
237237

238+
locals {
239+
# _- are invalid first characters
240+
# if - replace first char with J
241+
# elseif _ replace first char with K
242+
# else use asis
243+
admin_password = startswith(random_password.admin_password[0].result, "-") ? "J${substr(random_password.admin_password[0].result, 1, -1)}" : startswith(random_password.admin_password[0].result, "_") ? "K${substr(random_password.admin_password[0].result, 1, -1)}" : random_password.admin_password[0].result
244+
}
245+
238246
# create a service authorization between Secrets Manager and the target service (Elastic Search)
239247
resource "ibm_iam_authorization_policy" "secrets_manager_key_manager" {
240248
count = local.create_sm_auth_policy
@@ -277,7 +285,7 @@ locals {
277285
}
278286
]
279287

280-
admin_pass = var.admin_pass == null ? random_password.admin_password[0].result : var.admin_pass
288+
admin_pass = var.admin_pass == null ? local.admin_password : var.admin_pass
281289
admin_pass_secret = [{
282290
secret_group_name = var.prefix != null && var.admin_pass_sm_secret_group != null ? "${var.prefix}-${var.admin_pass_sm_secret_group}" : var.admin_pass_sm_secret_group
283291
existing_secret_group = var.use_existing_admin_pass_sm_secret_group

0 commit comments

Comments
 (0)