Skip to content

Commit ffa36e7

Browse files
authored
feat: added support to set a schema global compatibility rule using new input schema_global_rule. Feature is only valid for enterpirse plan instances. Allowed values are NONE, FULL, FULL_TRANSITIVE, FORWARD, FORWARD_TRANSITIVE, BACKWARD, BACKWARD_TRANSITIVE. (#342)
1 parent 59754d9 commit ffa36e7

File tree

7 files changed

+30
-1
lines changed

7 files changed

+30
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ You need the following permissions to run this module.
121121
|------|------|
122122
| [ibm_event_streams_quota.eventstreams_quotas](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_quota) | resource |
123123
| [ibm_event_streams_schema.es_schema](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_schema) | resource |
124+
| [ibm_event_streams_schema_global_rule.es_globalrule](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_schema_global_rule) | resource |
124125
| [ibm_event_streams_topic.es_topic](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_topic) | resource |
125126
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
126127
| [ibm_resource_instance.es_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
@@ -145,6 +146,7 @@ You need the following permissions to run this module.
145146
| <a name="input_quotas"></a> [quotas](#input\_quotas) | Quotas to be applied to the Event Streams instance. Entity may be 'default' to apply to all users, or an IAM ServiceID for a specific user. Rates are bytes/second, with -1 meaning no quota. | <pre>list(object({<br/> entity = string<br/> producer_byte_rate = optional(number, -1)<br/> consumer_byte_rate = optional(number, -1)<br/> }))</pre> | `[]` | no |
146147
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
147148
| <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 |
149+
| <a name="input_schema_global_rule"></a> [schema\_global\_rule](#input\_schema\_global\_rule) | Schema global compatibility rule. Allowed values are 'NONE', 'FULL', 'FULL\_TRANSITIVE', 'FORWARD', 'FORWARD\_TRANSITIVE', 'BACKWARD', 'BACKWARD\_TRANSITIVE'. | `string` | `null` | no |
148150
| <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 |
149151
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | The mapping of names and roles for service credentials that you want to create for the Event streams. | `map(string)` | `{}` | no |
150152
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The type of service endpoints. Possible values: 'public', 'private', 'public-and-private'. | `string` | `"public"` | no |

examples/fscloud/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module "event_streams" {
7070
"consumer_byte_rate" = 200000
7171
}
7272
]
73+
schema_global_rule = "FORWARD"
7374
service_credential_names = {
7475
"es_writer" : "Writer",
7576
"es_reader" : "Reader",

main.tf

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ locals {
2828
validate_metrics = var.plan != "enterprise-3nodes-2tb" && length(var.metrics) > 0 ? tobool("metrics are only supported for enterprise plan") : true
2929
# tflint-ignore: terraform_unused_declarations
3030
validate_quotas = var.plan != "enterprise-3nodes-2tb" && length(var.quotas) > 0 ? tobool("quotas are only supported for enterprise plan") : true
31+
# tflint-ignore: terraform_unused_declarations
32+
validate_schema_global_rule = var.plan != "enterprise-3nodes-2tb" && var.schema_global_rule != null ? tobool("schema global rule is only supported for enterprise plan") : true
3133
}
3234

3335
# workaround for https://github.com/IBM-Cloud/terraform-provider-ibm/issues/4478
@@ -70,7 +72,7 @@ resource "ibm_resource_instance" "es_instance" {
7072
}
7173

7274
##############################################################################
73-
# SCHEMA
75+
# SCHEMA AND COMPATIBILITY RULE
7476
##############################################################################
7577

7678
resource "ibm_event_streams_schema" "es_schema" {
@@ -80,6 +82,12 @@ resource "ibm_event_streams_schema" "es_schema" {
8082
schema = jsonencode(var.schemas[count.index].schema)
8183
}
8284

85+
resource "ibm_event_streams_schema_global_rule" "es_globalrule" {
86+
count = var.schema_global_rule != null ? 1 : 0
87+
resource_instance_id = ibm_resource_instance.es_instance.id
88+
config = var.schema_global_rule
89+
}
90+
8391
##############################################################################
8492
# TOPIC
8593
##############################################################################

modules/fscloud/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ No resources.
3535
| <a name="input_quotas"></a> [quotas](#input\_quotas) | Quotas to be applied to the Event Streams instance. Entity may be 'default' to apply to all users, or an IAM ServiceID for a specific user. Rates are bytes/second, with -1 meaning no quota. | <pre>list(object({<br/> entity = string<br/> producer_byte_rate = optional(number, -1)<br/> consumer_byte_rate = optional(number, -1)<br/> }))</pre> | `[]` | no |
3636
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
3737
| <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 |
38+
| <a name="input_schema_global_rule"></a> [schema\_global\_rule](#input\_schema\_global\_rule) | Schema global compatibility rule. Allowed values are 'NONE', 'FULL', 'FULL\_TRANSITIVE', 'FORWARD', 'FORWARD\_TRANSITIVE', 'BACKWARD', 'BACKWARD\_TRANSITIVE'. | `string` | `null` | no |
3839
| <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 |
3940
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | The mapping of names and roles for service credentials that you want to create for the Event streams. | `map(string)` | `{}` | no |
4041
| <a name="input_tags"></a> [tags](#input\_tags) | The list of tags associated with the Event Steams instance. | `list(string)` | `[]` | no |

modules/fscloud/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module "event_streams" {
77
kms_key_crn = var.kms_key_crn
88
existing_kms_instance_guid = var.existing_kms_instance_guid
99
schemas = var.schemas
10+
schema_global_rule = var.schema_global_rule
1011
tags = var.tags
1112
access_tags = var.access_tags
1213
topics = var.topics

modules/fscloud/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ variable "schemas" {
4646
default = []
4747
}
4848

49+
variable "schema_global_rule" {
50+
type = string
51+
description = "Schema global compatibility rule. Allowed values are 'NONE', 'FULL', 'FULL_TRANSITIVE', 'FORWARD', 'FORWARD_TRANSITIVE', 'BACKWARD', 'BACKWARD_TRANSITIVE'."
52+
default = null
53+
}
54+
4955
variable "topics" {
5056
type = list(object(
5157
{

variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ variable "schemas" {
105105
default = []
106106
}
107107

108+
variable "schema_global_rule" {
109+
type = string
110+
description = "Schema global compatibility rule. Allowed values are 'NONE', 'FULL', 'FULL_TRANSITIVE', 'FORWARD', 'FORWARD_TRANSITIVE', 'BACKWARD', 'BACKWARD_TRANSITIVE'."
111+
default = null
112+
validation {
113+
condition = var.schema_global_rule == null || contains(["NONE", "FULL", "FULL_TRANSITIVE", "FORWARD", "FORWARD_TRANSITIVE", "BACKWARD", "BACKWARD_TRANSITIVE"], coalesce(var.schema_global_rule, "NONE"))
114+
error_message = "The schema_global_rule must be null or one of 'NONE', 'FULL', 'FULL_TRANSITIVE', 'FORWARD', 'FORWARD_TRANSITIVE', 'BACKWARD', 'BACKWARD_TRANSITIVE'."
115+
}
116+
}
117+
108118
variable "topics" {
109119
type = list(object(
110120
{

0 commit comments

Comments
 (0)