Skip to content

Commit 857e1fd

Browse files
authored
fix: fix bug when setting use_ibm_owned_encryption_key to true in the DA (#522)
1 parent bd9c2aa commit 857e1fd

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

solutions/standard/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module "kms" {
6464
providers = {
6565
ibm = ibm.kms
6666
}
67-
count = var.existing_kms_key_crn != null ? 0 : 1 # no need to create any KMS resources if passing an existing key or using IBM owned keys
67+
count = var.existing_kms_key_crn != null || var.use_ibm_owned_encryption_key ? 0 : 1 # no need to create any KMS resources if passing an existing key or using IBM owned keys
6868
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
6969
version = "4.16.8"
7070
create_key_protect_instance = false
@@ -133,7 +133,7 @@ module "backup_kms" {
133133
providers = {
134134
ibm = ibm.kms
135135
}
136-
count = var.existing_backup_kms_key_crn != null ? 0 : var.existing_backup_kms_instance_crn != null ? 1 : 0
136+
count = var.use_ibm_owned_encryption_key ? 0 : var.existing_backup_kms_key_crn != null ? 0 : var.existing_backup_kms_instance_crn != null ? 1 : 0
137137
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
138138
version = "4.16.8"
139139
create_key_protect_instance = false

solutions/standard/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ variable "auto_scaling" {
216216
##############################################################
217217

218218
variable "use_ibm_owned_encryption_key" {
219-
type = string
219+
type = bool
220220
description = "Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption."
221221
default = false
222222
}

tests/pr_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,30 @@ func TestRunStandardSolution(t *testing.T) {
122122
assert.NotNil(t, output, "Expected some output")
123123
}
124124

125+
// Test the DA when using IBM owned encryption keys
126+
func TestRunStandardSolutionIBMKeys(t *testing.T) {
127+
t.Parallel()
128+
129+
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
130+
Testing: t,
131+
TerraformDir: standardSolutionTerraformDir,
132+
Region: "us-south",
133+
Prefix: "postgres-icd-key",
134+
ResourceGroup: resourceGroup,
135+
})
136+
137+
options.TerraformVars = map[string]interface{}{
138+
"pg_version": "16",
139+
"provider_visibility": "public",
140+
"resource_group_name": options.Prefix,
141+
"use_ibm_owned_encryption_key": true,
142+
}
143+
144+
output, err := options.RunTestConsistency()
145+
assert.Nil(t, err, "This should not have errored")
146+
assert.NotNil(t, output, "Expected some output")
147+
}
148+
125149
func TestRunStandardUpgradeSolution(t *testing.T) {
126150
t.Parallel()
127151

0 commit comments

Comments
 (0)