Skip to content

Commit f20ea1f

Browse files
authored
fix: fixed bug in KMS validation logic (#46)
1 parent ff6f933 commit f20ea1f

File tree

4 files changed

+10
-60
lines changed

4 files changed

+10
-60
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ You need the following permissions to run this module.
117117
## Examples
118118

119119
- [ Basic example](examples/basic)
120-
- [ Complete example with topics and schema creation and BYOK encryption](examples/complete)
120+
- [ Complete example with topics and schema creation.](examples/complete)
121121
- [ Financial Services Cloud profile example](examples/fscloud)
122122
<!-- END EXAMPLES HOOK -->
123123
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/complete/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Complete example with topics and schema creation and BYOK encryption
1+
# Complete example with topics and schema creation.
22

33
An end-to-end example that creates an event streams instance with key protect.
44
This example uses the IBM Cloud terraform provider to:
55
- Create a new resource group if one is not passed in.
66
- Create a Key Protect instance and root key in the provided region.
7-
- Create a new event streams instance in the resource group and region provided, encrypted with the root key created above, and configured with topics and schemas.
7+
- Create a new event streams instance in the resource group and region provided along with configured topics and schemas.

examples/complete/main.tf

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,65 +10,15 @@ module "resource_group" {
1010
existing_resource_group_name = var.resource_group
1111
}
1212

13-
##############################################################################
14-
# Key Protect All Inclusive
15-
##############################################################################
16-
17-
module "key_protect_all_inclusive" {
18-
source = "terraform-ibm-modules/key-protect-all-inclusive/ibm"
19-
version = "4.2.0"
20-
key_protect_instance_name = "${var.prefix}-kp"
21-
resource_group_id = module.resource_group.resource_group_id
22-
region = var.region
23-
resource_tags = var.resource_tags
24-
key_map = { "es" = ["${var.prefix}-es"] }
25-
enable_metrics = false
26-
}
27-
28-
##############################################################################
29-
# Get Cloud Account ID
30-
##############################################################################
31-
32-
data "ibm_iam_account_settings" "iam_account_settings" {
33-
}
34-
35-
##############################################################################
36-
# VPC
37-
##############################################################################
38-
resource "ibm_is_vpc" "example_vpc" {
39-
name = "${var.prefix}-vpc"
40-
resource_group = module.resource_group.resource_group_id
41-
tags = var.resource_tags
42-
}
43-
44-
##############################################################################
45-
# Create CBR Zone
46-
##############################################################################
47-
module "cbr_zone" {
48-
source = "terraform-ibm-modules/cbr/ibm//cbr-zone-module"
49-
version = "1.2.0"
50-
name = "${var.prefix}-VPC-network-zone"
51-
zone_description = "CBR Network zone representing VPC"
52-
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
53-
addresses = [{
54-
type = "vpc", # to bind a specific vpc to the zone
55-
value = ibm_is_vpc.example_vpc.crn,
56-
}]
57-
}
58-
59-
6013
##############################################################################
6114
# Events-streams-instance
6215
##############################################################################
6316

6417
module "event_streams" {
65-
source = "../../"
66-
resource_group_id = module.resource_group.resource_group_id
67-
es_name = "${var.prefix}-es"
68-
kms_encryption_enabled = true
69-
kms_key_crn = module.key_protect_all_inclusive.keys["es.${var.prefix}-es"].crn
70-
existing_kms_instance_guid = module.key_protect_all_inclusive.key_protect_guid
71-
schemas = var.schemas
72-
tags = var.resource_tags
73-
topics = var.topics
18+
source = "../../"
19+
resource_group_id = module.resource_group.resource_group_id
20+
es_name = "${var.prefix}-es"
21+
schemas = var.schemas
22+
tags = var.resource_tags
23+
topics = var.topics
7424
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
locals {
66
# Validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
77
# tflint-ignore: terraform_unused_declarations
8-
validate_kms_plan = var.kms_encryption_enabled != null && var.plan != "enterprise-3nodes-2tb" ? tobool("kms encryption is only supported for enterprise plan") : true
8+
validate_kms_plan = var.kms_encryption_enabled && var.plan != "enterprise-3nodes-2tb" ? tobool("kms encryption is only supported for enterprise plan") : true
99
# tflint-ignore: terraform_unused_declarations
1010
validate_kms_values = !var.kms_encryption_enabled && var.kms_key_crn != null ? tobool("When passing values for var.kms_key_crn, you must set var.kms_encryption_enabled to true. Otherwise unset them to use default encryption") : true
1111
# tflint-ignore: terraform_unused_declarations

0 commit comments

Comments
 (0)