Skip to content

Commit 1186809

Browse files
authored
feat: store Kibana account secrets in secrets manager if provided
1 parent 341800c commit 1186809

File tree

5 files changed

+75
-10
lines changed

5 files changed

+75
-10
lines changed

ibm_catalog.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@
458458
{
459459
"key": "kibana_image_port"
460460
},
461+
{
462+
"key": "kibana_system_secret_name"
463+
},
464+
{
465+
"key": "kibana_app_secret_name"
466+
},
461467
{
462468
"key": "cbr_code_engine_kibana_project_rules"
463469
},
@@ -841,6 +847,12 @@
841847
{
842848
"key": "kibana_image_port"
843849
},
850+
{
851+
"key": "kibana_system_secret_name"
852+
},
853+
{
854+
"key": "kibana_app_secret_name"
855+
},
844856
{
845857
"key": "cbr_rules",
846858
"type": "array",

solutions/fully-configurable/main.tf

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,20 +396,34 @@ locals {
396396
}
397397
]
398398

399+
# Prepare locally generated secrets
400+
system_secrets = [{
401+
"secret_name" = "${local.prefix}${var.admin_pass_secrets_manager_secret_name}"
402+
"secret_type" = "arbitrary"
403+
"secret_payload_password" = local.admin_pass
404+
}]
405+
kibana_secrets = var.enable_kibana_dashboard ? [{
406+
"secret_name" = "${local.prefix}${var.kibana_system_secret_name}"
407+
"secret_type" = "arbitrary"
408+
"secret_payload_password" = local.kibana_system_password
409+
},
410+
{
411+
"secret_name" = "${local.prefix}${var.kibana_app_secret_name}"
412+
"secret_type" = "arbitrary"
413+
"secret_payload_password" = local.kibana_app_login_password
414+
}] : []
415+
password_secrets = concat(local.system_secrets, local.kibana_secrets)
416+
417+
399418
# Build the structure of the arbitrary credential type secret for admin password
400-
admin_pass_secret = [{
419+
user_secrets = [{
401420
secret_group_name = "${local.prefix}${var.admin_pass_secrets_manager_secret_group}"
402421
existing_secret_group = var.use_existing_admin_pass_secrets_manager_secret_group
403-
secrets = [{
404-
secret_name = "${local.prefix}${var.admin_pass_secrets_manager_secret_name}"
405-
secret_type = "arbitrary"
406-
secret_payload_password = local.admin_pass
407-
}
408-
]
422+
secrets = local.password_secrets
409423
}]
410424

411425
# Concatenate into 1 secrets object
412-
secrets = concat(local.service_credential_secrets, local.admin_pass_secret)
426+
secrets = concat(local.service_credential_secrets, local.user_secrets)
413427
# Parse Secrets Manager details from the CRN
414428
existing_secrets_manager_instance_guid = var.existing_secrets_manager_instance_crn != null ? module.sm_instance_crn_parser[0].service_instance : null
415429
existing_secrets_manager_instance_region = var.existing_secrets_manager_instance_crn != null ? module.sm_instance_crn_parser[0].region : null

solutions/fully-configurable/variables.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,32 @@ variable "kibana_registry_personal_access_token" {
581581
}
582582
}
583583

584+
variable "kibana_system_secret_name" {
585+
type = string
586+
description = "The Secrets Manager secret name of a new kibana system secret. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
587+
default = "kibana-system-password"
588+
589+
validation {
590+
condition = (
591+
!(var.enable_kibana_dashboard && var.existing_secrets_manager_instance_crn != null && length(var.kibana_system_secret_name) == 0)
592+
)
593+
error_message = "`kibana_system_secret_name` is required when `existing_secrets_manager_instance_crn` and `enable_kibana_dashboard` are set."
594+
}
595+
}
596+
597+
variable "kibana_app_secret_name" {
598+
type = string
599+
description = "The Secrets Manager secret name of a new kibana application secret. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
600+
default = "kibana-app-password"
601+
602+
validation {
603+
condition = (
604+
!(var.enable_kibana_dashboard && var.existing_secrets_manager_instance_crn != null && length(var.kibana_app_secret_name) == 0)
605+
)
606+
error_message = "`kibana_app_secret_name` is required when `existing_secrets_manager_instance_crn` and `enable_kibana_dashboard` are set."
607+
}
608+
}
609+
584610
##############################################################
585611
# Context-based restriction (CBR)
586612
##############################################################

solutions/security-enforced/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ module "elasticsearch" {
5353
kibana_image_digest = var.kibana_image_digest
5454
kibana_image_port = var.kibana_image_port
5555
kibana_visibility = "local_private"
56+
kibana_system_secret_name = var.kibana_system_secret_name
57+
kibana_app_secret_name = var.kibana_app_secret_name
5658
cbr_rules = var.cbr_rules
5759
}

solutions/security-enforced/variables.tf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,26 @@ variable "kibana_image_digest" {
431431
condition = var.kibana_image_digest == null || can(regex("^sha256:", var.kibana_image_digest))
432432
error_message = "If provided, the value of kibana_image_digest must start with 'sha256:'."
433433
}
434-
435-
436434
}
435+
437436
variable "kibana_image_port" {
438437
description = "Specify the port number used to connect to the Kibana service exposed by the container image. Default port is 5601 and it is only applicable if `enable_kibana_dashboard` is true"
439438
type = number
440439
default = 5601
441440
}
442441

442+
variable "kibana_system_secret_name" {
443+
type = string
444+
description = "The Secrets Manager secret name of a new kibana system secret. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
445+
default = "kibana-system-password"
446+
}
447+
448+
variable "kibana_app_secret_name" {
449+
type = string
450+
description = "The Secrets Manager secret name of a new kibana application secret. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
451+
default = "kibana-app-password"
452+
}
453+
443454
##############################################################
444455
# Context-based restriction (CBR)
445456
##############################################################

0 commit comments

Comments
 (0)