Skip to content

Commit b1431d5

Browse files
committed
SKIP UPGRADE TEST, add kms_encryption_enabled variable
1 parent 01ac193 commit b1431d5

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-05-02T09:58:59Z",
6+
"generated_at": "2025-05-02T13:16:14Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -110,7 +110,7 @@
110110
"hashed_secret": "8c7c51db5075ebd0369c51e9f14737d9b4c1c21d",
111111
"is_secret": false,
112112
"is_verified": false,
113-
"line_number": 356,
113+
"line_number": 361,
114114
"type": "Base64 High Entropy String",
115115
"verified_result": null
116116
}

cra-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CRA_TARGETS:
66
PROFILE_ID: "fe96bd4d-9b37-40f2-b39f-a62760e326a3" # SCC profile ID (currently set to 'IBM Cloud Framework for Financial Services' '1.7.0' profile).
77
CRA_ENVIRONMENT_VARIABLES:
88
TF_VAR_prefix: "test"
9+
TF_VAR_kms_encryption_enabled: true
910
TF_VAR_use_ibm_owned_encryption_key: false
1011
TF_VAR_existing_kms_instance_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9::"
1112
TF_VAR_provider_visibility: "public"

ibm_catalog.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@
317317
}
318318
]
319319
},
320+
{
321+
"key": "kms_encryption_enabled"
322+
},
320323
{
321324
"key": "use_ibm_owned_encryption_key"
322325
},

solutions/fully-configurable/variables.tf

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,28 +227,32 @@ variable "auto_scaling" {
227227
# Encryption
228228
##############################################################
229229

230-
variable "use_ibm_owned_encryption_key" {
230+
variable "kms_encryption_enabled" {
231231
type = bool
232-
description = "IBM Cloud Databases will secure your deployment's data at rest automatically with an encryption key that IBM hold. Alternatively, you may select your own Key Management System instance and encryption key (Key Protect or Hyper Protect Crypto Services) by setting this to false. If setting to false, a value must be passed for `existing_kms_instance_crn` to create a new key, or `existing_kms_key_crn` and/or `existing_backup_kms_key_crn` to use an existing key."
233-
default = true
232+
description = "Set to true to enable KMS Encryption using customer managed keys. When set to true, a value must be passed for either 'existing_kms_instance_crn', 'existing_kms_key_crn' or 'existing_backup_kms_key_crn'."
233+
default = false
234234

235235
validation {
236-
condition = (
237-
!var.use_ibm_owned_encryption_key ? length(compact([var.existing_kms_instance_crn, var.existing_kms_key_crn, var.existing_backup_kms_key_crn])) > 0 : true
238-
)
239-
error_message = "When not using ibm owned encryption keys by setting variable 'use_ibm_owned_encryption_key' to false, 'existing_kms_instance_crn', 'existing_kms_key_crn' or 'existing_backup_kms_key_crn' must be set."
236+
condition = var.kms_encryption_enabled ? var.existing_kms_instance_crn != null || var.existing_kms_key_crn != null || var.existing_backup_kms_key_crn != null : true
237+
error_message = "When variable `kms_encryption_enabled` is true and KMS encryption is enabled, you must provide either an existing KMS instance with variable `existing_kms_instance_crn` or an existing KMS key using variable `existing_kms_key_crn` or `existing_backup_kms_key_crn`"
240238
}
239+
}
240+
241+
variable "use_ibm_owned_encryption_key" {
242+
type = bool
243+
description = "IBM Cloud Databases will secure your deployment's data at rest automatically with an encryption key that IBM hold. Alternatively, you may select your own Key Management System instance and encryption key (Key Protect or Hyper Protect Crypto Services) by setting this to false. If setting to false, a value must be passed for `existing_kms_instance_crn` to create a new key, or `existing_kms_key_crn` and/or `existing_backup_kms_key_crn` to use an existing key."
244+
default = true
241245

242246
validation {
243-
condition = !var.use_ibm_owned_encryption_key && var.existing_kms_instance_crn == null ? (var.existing_kms_key_crn != null || var.existing_backup_kms_key_crn != null) : true
244-
error_message = "When not using ibm owned encryption, you must provide either an existing KMS instance with variable `existing_kms_instance_crn` or an existing KMS key using variable `existing_kms_key_crn` or `existing_backup_kms_key_crn`"
247+
condition = var.use_ibm_owned_encryption_key ? !var.kms_encryption_enabled : true
248+
error_message = "When variable `use_ibm_owned_encryption_key` is true, `kms_encryption_enabled` should be set to false"
245249
}
246250

247251
validation {
248252
condition = (
249253
var.use_ibm_owned_encryption_key ? length(compact([var.existing_kms_instance_crn, var.existing_kms_key_crn, var.existing_backup_kms_key_crn])) == 0 : true
250254
)
251-
error_message = "When using ibm owned encryption keys by setting variable 'use_ibm_owned_encryption_key' to true, 'existing_kms_instance_crn', 'existing_kms_key_crn' and 'existing_backup_kms_key_crn' must not be set."
255+
error_message = "When using ibm owned encryption keys by setting variable 'use_ibm_owned_encryption_key' to true, 'existing_kms_instance_crn', 'existing_kms_key_crn' and 'existing_backup_kms_key_crn' should not be set."
252256
}
253257
}
254258

solutions/security-enforced/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module "elasticsearch" {
2626
# Auto Scaling
2727
auto_scaling = var.auto_scaling
2828
# Encryption
29+
kms_encryption_enabled = true
2930
use_ibm_owned_encryption_key = false
3031
existing_kms_instance_crn = var.existing_kms_instance_crn
3132
existing_kms_key_crn = var.existing_kms_key_crn

tests/pr_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func TestRunFullyConfigurableSolutionSchematics(t *testing.T) {
9696
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
9797
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
9898
{Name: "elasticsearch_access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"},
99+
{Name: "kms_encryption_enabled", Value: true, DataType: "bool"},
99100
{Name: "use_ibm_owned_encryption_key", Value: false, DataType: "bool"},
100101
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
101102
{Name: "kms_endpoint_type", Value: "private", DataType: "string"},
@@ -132,6 +133,7 @@ func TestRunFullyConfigurableUpgradeSolution(t *testing.T) {
132133
options.TerraformVars = map[string]interface{}{
133134
"prefix": options.Prefix,
134135
"elasticsearch_access_tags": permanentResources["accessTags"],
136+
"kms_encryption_enabled": true,
135137
"use_ibm_owned_encryption_key": false,
136138
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
137139
"kms_endpoint_type": "public",
@@ -187,6 +189,7 @@ func TestRunSecurityEnforcedSolutionSchematics(t *testing.T) {
187189

188190
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
189191
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
192+
{Name: "kms_encryption_enabled", Value: true, DataType: "bool"},
190193
{Name: "use_ibm_owned_encryption_key", Value: false, DataType: "bool"},
191194
{Name: "elasticsearch_access_tags", Value: permanentResources["accessTags"], DataType: "list(string)"},
192195
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},
@@ -330,6 +333,7 @@ func TestPlanValidation(t *testing.T) {
330333

331334
// Test the DA when using Elser model
332335
var fullyConfigurableSolutionWithElserModelVars = map[string]interface{}{
336+
"kms_encryption_enabled": true,
333337
"use_ibm_owned_encryption_key": false,
334338
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
335339
"enable_elser_model": true,
@@ -339,6 +343,7 @@ func TestPlanValidation(t *testing.T) {
339343
// Test the DA when using Kibana dashboard and existing KMS instance
340344
var fullyConfigurableSolutionWithKibanaDashboardVars = map[string]interface{}{
341345
"enable_kibana_dashboard": true,
346+
"kms_encryption_enabled": true,
342347
"use_ibm_owned_encryption_key": false,
343348
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
344349
"plan": "enterprise",

0 commit comments

Comments
 (0)