Skip to content

Commit e7ad046

Browse files
authored
feat: removed kms_region from the DA input as its now programmatically determined.<br>* The existing_kms_instance_guid input variable has been replaced by the existing_kms_instance_crn in the DA solution. The CRN should now be passed to it instead of the GUID. (#190)
1 parent 8584d64 commit e7ad046

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

solutions/secure/catalogValidationValues.json.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"tags": $TAGS,
55
"name": $PREFIX,
66
"resource_group_name": $PREFIX,
7-
"existing_kms_instance_guid": $HPCS_US_SOUTH_GUID,
8-
"kms_region": "us-south"
7+
"existing_kms_instance_crn": $HPCS_US_SOUTH_CRN
98
}

solutions/secure/main.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
locals {
2+
existing_kms_instance_crn_split = var.existing_kms_instance_crn != null ? split(":", var.existing_kms_instance_crn) : null
3+
existing_kms_instance_guid = var.existing_kms_instance_crn != null ? element(local.existing_kms_instance_crn_split, length(local.existing_kms_instance_crn_split) - 3) : null
4+
existing_kms_instance_region = var.existing_kms_instance_crn != null ? element(local.existing_kms_instance_crn_split, length(local.existing_kms_instance_crn_split) - 5) : null
5+
}
6+
17
module "resource_group" {
28
source = "terraform-ibm-modules/resource-group/ibm"
39
version = "1.1.5"
@@ -14,8 +20,8 @@ module "kms" {
1420
source = "terraform-ibm-modules/kms-all-inclusive/ibm"
1521
version = "4.13.2"
1622
create_key_protect_instance = false
17-
region = var.kms_region
18-
existing_kms_instance_guid = var.existing_kms_instance_guid
23+
region = local.existing_kms_instance_region
24+
existing_kms_instance_guid = local.existing_kms_instance_guid
1925
key_ring_endpoint_type = var.kms_endpoint_type
2026
key_endpoint_type = var.kms_endpoint_type
2127
keys = [
@@ -48,7 +54,7 @@ module "elasticsearch" {
4854
plan = var.plan
4955
skip_iam_authorization_policy = var.skip_iam_authorization_policy
5056
elasticsearch_version = var.elasticsearch_version
51-
existing_kms_instance_guid = var.existing_kms_instance_guid
57+
existing_kms_instance_guid = local.existing_kms_instance_guid
5258
kms_key_crn = local.kms_key_crn
5359
access_tags = var.access_tags
5460
tags = var.tags

solutions/secure/variables.tf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,6 @@ variable "tags" {
9898
default = []
9999
}
100100

101-
variable "kms_region" {
102-
type = string
103-
default = "us-south"
104-
description = "The region in which KMS instance exists."
105-
}
106-
107101
variable "kms_endpoint_type" {
108102
type = string
109103
description = "The type of endpoint to be used for commincating with the KMS instance. Allowed values are: 'public' or 'private' (default)"
@@ -120,8 +114,8 @@ variable "existing_kms_key_crn" {
120114
default = null
121115
}
122116

123-
variable "existing_kms_instance_guid" {
124-
description = "The GUID of an existing Hyper Protect or Key Protect instance in the same account as the Elasticsearch database instance. Always used to create an authorization policy and if 'existing_kms_key_crn' is not specified also used to create a KMS root key"
117+
variable "existing_kms_instance_crn" {
118+
description = "The CRN of an existing Hyper Protect or Key Protect instance in the same account as the Elasticsearch database instance. Always used to create an authorization policy and if 'existing_kms_key_crn' is not specified also used to create a KMS root key"
125119
type = string
126120
default = null
127121
}

tests/pr_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ func setupOptionsSecureSolution(t *testing.T, prefix string) *testhelper.TestOpt
8989
})
9090

9191
options.TerraformVars = map[string]interface{}{
92-
"access_tags": permanentResources["accessTags"],
93-
"existing_kms_instance_guid": permanentResources["hpcs_south"],
94-
"kms_endpoint_type": "public",
95-
"resource_group_name": options.Prefix,
96-
"name": options.Prefix,
92+
"access_tags": permanentResources["accessTags"],
93+
"existing_kms_instance_crn": permanentResources["hpcs_south_crn"],
94+
"kms_endpoint_type": "public",
95+
"resource_group_name": options.Prefix,
96+
"name": options.Prefix,
9797
}
9898

9999
return options

0 commit comments

Comments
 (0)