Skip to content

Commit 43f070c

Browse files
Jordan-Williams2Jordan-Williams2
authored andcommitted
fix: add test and fix bug
1 parent 5c62f40 commit 43f070c

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

modules/fscloud/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ No resources.
5353
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | Map of name, role for service credentials that you want to create for the database | `map(string)` | `{}` | no |
5454
| <a name="input_skip_iam_authorization_policy"></a> [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all ElasticSearch database instances in the resource group to read the encryption key from the Hyper Protect Crypto Services or Key Protect instance. The instance is passed in through the var.existing\_kms\_instance\_guid variable. | `bool` | `false` | no |
5555
| <a name="input_tags"></a> [tags](#input\_tags) | Optional list of tags to be added to the Elasticsearch instance. | `list(any)` | `[]` | no |
56-
| <a name="input_use_ibm_owned_encryption_key"></a> [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption. To control the encryption keys, use the `kms_key_crn` and `backup_encryption_key_crn` inputs. | `string` | `false` | no |
56+
| <a name="input_use_ibm_owned_encryption_key"></a> [use\_ibm\_owned\_encryption\_key](#input\_use\_ibm\_owned\_encryption\_key) | Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption. To control the encryption keys, use the `kms_key_crn` and `backup_encryption_key_crn` inputs. | `bool` | `false` | no |
5757
| <a name="input_users"></a> [users](#input\_users) | A list of users that you want to create on the database. Multiple blocks are allowed. The user password must be in the range of 10-32 characters. Be warned that in most case using IAM service credentials (via the var.service\_credential\_names) is sufficient to control access to the Elasticsearch instance. This blocks creates native Elasticsearch database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-elasticsearch?topic=databases-for-elasticsearch-user-management&interface=ui | <pre>list(object({<br/> name = string<br/> password = string # pragma: allowlist secret<br/> type = optional(string)<br/> role = optional(string)<br/> }))</pre> | `[]` | no |
5858

5959
### Outputs

modules/fscloud/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ variable "auto_scaling" {
137137
##############################################################
138138

139139
variable "use_ibm_owned_encryption_key" {
140-
type = string
140+
type = bool
141141
description = "Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption. To control the encryption keys, use the `kms_key_crn` and `backup_encryption_key_crn` inputs."
142142
default = false
143143
}

solutions/standard/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module "kms" {
6767
providers = {
6868
ibm = ibm.kms
6969
}
70-
count = var.existing_kms_key_crn != null || local.use_existing_db_instance ? 0 : 1 # no need to create any KMS resources if passing an existing key or using IBM owned keys
70+
count = var.existing_kms_key_crn != null || local.use_existing_db_instance || 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
7171
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
7272
version = "4.16.4"
7373
create_key_protect_instance = false

solutions/standard/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ variable "elasticsearch_key_ring_name" {
245245
}
246246

247247
variable "use_ibm_owned_encryption_key" {
248-
type = string
248+
type = bool
249249
description = "Set to true to use the default IBM Cloud® Databases randomly generated keys for disk and backups encryption."
250250
default = false
251251
}

tests/pr_test.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ func TestRunStandardSolutionSchematics(t *testing.T) {
165165

166166
serviceCredentialSecrets := []map[string]interface{}{
167167
{
168-
"secret_group_name": fmt.Sprintf("%s-secret-group", prefix),
168+
"secret_group_name": fmt.Sprintf("%s-secret-group", options.Prefix),
169169
"service_credentials": []map[string]string{
170170
{
171-
"secret_name": fmt.Sprintf("%s-cred-reader", prefix),
171+
"secret_name": fmt.Sprintf("%s-cred-reader", options.Prefix),
172172
"service_credentials_source_service_role": "Reader",
173173
},
174174
{
175-
"secret_name": fmt.Sprintf("%s-cred-writer", prefix),
175+
"secret_name": fmt.Sprintf("%s-cred-writer", options.Prefix),
176176
"service_credentials_source_service_role": "Writer",
177177
},
178178
},
@@ -248,3 +248,27 @@ func TestRunBasicExample(t *testing.T) {
248248
assert.Nil(t, err, "This should not have errored")
249249
assert.NotNil(t, output, "Expected some output")
250250
}
251+
252+
// Test the DA when using IBM owned encryption keys
253+
func TestRunStandardSolutionIBMKeys(t *testing.T) {
254+
t.Parallel()
255+
256+
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{
257+
Testing: t,
258+
TerraformDir: standardSolutionTerraformDir,
259+
Region: "us-south",
260+
Prefix: "es-icd-key",
261+
ResourceGroup: resourceGroup,
262+
})
263+
264+
options.TerraformVars = map[string]interface{}{
265+
"elasticsearch_version": "8.12",
266+
"provider_visibility": "public",
267+
"resource_group_name": options.Prefix,
268+
"use_ibm_owned_encryption_key": true,
269+
}
270+
271+
output, err := options.RunTestConsistency()
272+
assert.Nil(t, err, "This should not have errored")
273+
assert.NotNil(t, output, "Expected some output")
274+
}

0 commit comments

Comments
 (0)