Skip to content

Commit 097ca90

Browse files
authored
feat: added support to activate metrics using new metrics list input variable. The list can contain the following allowed values: "topic", "partition", and "consumers" (#319)
1 parent 51e8961 commit 097ca90

File tree

8 files changed

+25
-0
lines changed

8 files changed

+25
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ You need the following permissions to run this module.
139139
| <a name="input_existing_kms_instance_guid"></a> [existing\_kms\_instance\_guid](#input\_existing\_kms\_instance\_guid) | The GUID of the Hyper Protect Crypto Services or Key Protect instance in which the key specified in var.kms\_key\_crn is coming from. Required only if var.kms\_encryption\_enabled is set to true, var.skip\_iam\_authorization\_policy is set to false, and you pass a value for var.kms\_key\_crn. | `string` | `null` | no |
140140
| <a name="input_kms_encryption_enabled"></a> [kms\_encryption\_enabled](#input\_kms\_encryption\_enabled) | Set this to true to control the encryption keys used to encrypt the data that you store in IBM Cloud® Databases. If set to false, the data is encrypted by using randomly generated keys. For more info on Key Protect integration, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect. For more info on HPCS integration, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs | `bool` | `false` | no |
141141
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of the key management service (Key Protect or Hyper Protect Crypto Services) to use to encrypt the payload data. [Learn more](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-managing_encryption) about integrating Hyper Protect Crypto Services with Event Streams. | `string` | `null` | no |
142+
| <a name="input_metrics"></a> [metrics](#input\_metrics) | Enhanced metrics to activate, as list of strings. Only allowed for enterprise plans. Allowed values: 'topic', 'partition', 'consumers'. | `list(string)` | `[]` | no |
142143
| <a name="input_plan"></a> [plan](#input\_plan) | The plan for the Event Streams instance. Possible values: `lite`, `standard`, `enterprise-3nodes-2tb`. | `string` | `"standard"` | no |
143144
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
144145
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the Event Streams instance is created. | `string` | n/a | yes |

examples/complete/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module "event_streams" {
2222
tags = var.resource_tags
2323
access_tags = var.access_tags
2424
topics = var.topics
25+
metrics = []
2526
service_credential_names = {
2627
"es_writer" : "Writer",
2728
"es_reader" : "Reader",

examples/fscloud/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module "event_streams" {
6262
tags = var.resource_tags
6363
topics = var.topics
6464
existing_kms_instance_guid = var.existing_kms_instance_guid
65+
metrics = ["topic", "partition", "consumers"]
6566
service_credential_names = {
6667
"es_writer" : "Writer",
6768
"es_reader" : "Reader",

main.tf

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ locals {
2424
can(regex(".*hs-crypto.*", var.kms_key_crn)) ? "hs-crypto" : null
2525
)
2626
) : null
27+
# tflint-ignore: terraform_unused_declarations
28+
validate_metrics = var.plan != "enterprise-3nodes-2tb" && length(var.metrics) > 0 ? tobool("metrics are only supported for enterprise plan") : true
2729
}
2830

2931
# workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4478
@@ -52,13 +54,15 @@ resource "ibm_resource_instance" "es_instance" {
5254
service-endpoints = var.service_endpoints
5355
throughput = tostring(var.throughput)
5456
storage_size = tostring(var.storage_size)
57+
metrics = var.metrics
5558
kms_key_crn = var.kms_key_crn
5659
}
5760
) : jsonencode(
5861
{
5962
service-endpoints = var.service_endpoints
6063
throughput = tostring(var.throughput)
6164
storage_size = tostring(var.storage_size)
65+
metrics = var.metrics
6266
}
6367
)
6468
}

modules/fscloud/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ No resources.
3131
| <a name="input_es_name"></a> [es\_name](#input\_es\_name) | The name of the Event Streams instance. | `string` | n/a | yes |
3232
| <a name="input_existing_kms_instance_guid"></a> [existing\_kms\_instance\_guid](#input\_existing\_kms\_instance\_guid) | The GUID of the Hyper Protect Crypto service in which the key specified in var.kms\_key\_crn is coming from | `string` | n/a | yes |
3333
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of the key management service (Key Protect or Hyper Protect Crypto Services) to use to encrypt the payload data. | `string` | n/a | yes |
34+
| <a name="input_metrics"></a> [metrics](#input\_metrics) | Enhanced metrics to activate, as list of strings. Allowed values: 'topic', 'partition', 'consumers'. | `list(string)` | `[]` | no |
3435
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
3536
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the Event Streams instance is created. | `string` | n/a | yes |
3637
| <a name="input_schemas"></a> [schemas](#input\_schemas) | The list of schema objects. Include the `schema_id` and the `type` and `name` of the schema in the `schema` object. | <pre>list(object(<br/> {<br/> schema_id = string<br/> schema = object({<br/> type = string<br/> name = string<br/> fields = optional(list(object({<br/> name = string<br/> type = string<br/> })))<br/> })<br/> }<br/> ))</pre> | `[]` | no |

modules/fscloud/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module "event_streams" {
1313
service_endpoints = "private"
1414
cbr_rules = var.cbr_rules
1515
service_credential_names = var.service_credential_names
16+
metrics = var.metrics
1617
kms_encryption_enabled = true
1718

1819
}

modules/fscloud/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,9 @@ variable "service_credential_names" {
9393
type = map(string)
9494
default = {}
9595
}
96+
97+
variable "metrics" {
98+
type = list(string)
99+
description = "Enhanced metrics to activate, as list of strings. Allowed values: 'topic', 'partition', 'consumers'."
100+
default = []
101+
}

variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,13 @@ variable "service_credential_names" {
191191
error_message = "The specified service credential role is not valid. The following values are valid for service credential roles: 'Writer', 'Reader', 'Manager'"
192192
}
193193
}
194+
195+
variable "metrics" {
196+
type = list(string)
197+
description = "Enhanced metrics to activate, as list of strings. Only allowed for enterprise plans. Allowed values: 'topic', 'partition', 'consumers'."
198+
validation {
199+
condition = alltrue([for name in var.metrics : contains(["topic", "partition", "consumers"], name)])
200+
error_message = "The specified metrics are not valid. The following values are valid for metrics: 'topic', 'partition', 'consumers'."
201+
}
202+
default = []
203+
}

0 commit comments

Comments
 (0)