Skip to content

Commit 8503424

Browse files
authored
feat: added mirroring support. It can be used with the new optional inputs mirroring and mirroring_topic_patterns. NOTE: This is only supported with enterprise plan instances. (#327)
1 parent 06724d4 commit 8503424

15 files changed

+333
-73
lines changed

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,25 @@ You need the following permissions to run this module.
114114
| Name | Source | Version |
115115
|------|--------|---------|
116116
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.29.0 |
117+
| <a name="module_es_guid_crn_parser"></a> [es\_guid\_crn\_parser](#module\_es\_guid\_crn\_parser) | terraform-ibm-modules/common-utilities/ibm//modules/crn-parser | 1.1.0 |
117118

118119
### Resources
119120

120121
| Name | Type |
121122
|------|------|
123+
| [ibm_event_streams_mirroring_config.es_mirroring_config](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_mirroring_config) | resource |
122124
| [ibm_event_streams_quota.eventstreams_quotas](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_quota) | resource |
123125
| [ibm_event_streams_schema.es_schema](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_schema) | resource |
124126
| [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 |
125127
| [ibm_event_streams_topic.es_topic](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_topic) | resource |
128+
| [ibm_iam_authorization_policy.es_s2s_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
126129
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
127130
| [ibm_resource_instance.es_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
128131
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
129132
| [ibm_resource_tag.es_access_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
130133
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
134+
| [time_sleep.wait_for_es_s2s_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
135+
| [time_sleep.wait_for_kms_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
131136

132137
### Inputs
133138

@@ -138,10 +143,12 @@ You need the following permissions to run this module.
138143
| <a name="input_create_timeout"></a> [create\_timeout](#input\_create\_timeout) | The timeout value for creating an Event Streams instance. Specify `3h` for an Enterprise plan instance. Add 1 h for each level of non-default throughput. Add 30 min for each level of non-default storage size. | `string` | `"3h"` | no |
139144
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | The timeout value for deleting an Event Streams instance. | `string` | `"15m"` | no |
140145
| <a name="input_es_name"></a> [es\_name](#input\_es\_name) | The name to give the Event Streams instance created by this module. | `string` | n/a | yes |
141-
| <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 |
146+
| <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\_kms\_iam\_authorization\_policy is set to false, and you pass a value for var.kms\_key\_crn. | `string` | `null` | no |
142147
| <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 |
143148
| <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 |
144149
| <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 |
150+
| <a name="input_mirroring"></a> [mirroring](#input\_mirroring) | Event Streams mirroring configuration. Required only if creating mirroring instance. For more information on mirroring, see https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-mirroring. | <pre>object({<br/> source_crn = string<br/> source_alias = string<br/> target_alias = string<br/> options = optional(object({<br/> topic_name_transform = object({<br/> type = string<br/> rename = optional(object({<br/> add_prefix = optional(string)<br/> add_suffix = optional(string)<br/> remove_prefix = optional(string)<br/> remove_suffix = optional(string)<br/> }))<br/> })<br/> group_id_transform = object({<br/> type = string<br/> rename = optional(object({<br/> add_prefix = optional(string)<br/> add_suffix = optional(string)<br/> remove_prefix = optional(string)<br/> remove_suffix = optional(string)<br/> }))<br/> })<br/> }))<br/> })</pre> | `null` | no |
151+
| <a name="input_mirroring_topic_patterns"></a> [mirroring\_topic\_patterns](#input\_mirroring\_topic\_patterns) | The list of the topics to set in instance. Required only if creating mirroring instance. | `list(string)` | `null` | no |
145152
| <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 |
146153
| <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 |
147154
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
@@ -150,7 +157,8 @@ You need the following permissions to run this module.
150157
| <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 |
151158
| <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 |
152159
| <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 |
153-
| <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 Event Streams database instances in the resource group to read the encryption key from the KMS instance. If set to false, pass in a value for the KMS instance in the existing\_kms\_instance\_guid variable. In addition, no policy is created if var.kms\_encryption\_enabled is set to false. | `bool` | `false` | no |
160+
| <a name="input_skip_es_s2s_iam_authorization_policy"></a> [skip\_es\_s2s\_iam\_authorization\_policy](#input\_skip\_es\_s2s\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that will allow all Event Streams instances in the given resource group access to read from the mirror source instance. This policy is required when creating a mirroring instance, and will only be created if a value is passed in the mirroring input. | `bool` | `false` | no |
161+
| <a name="input_skip_kms_iam_authorization_policy"></a> [skip\_kms\_iam\_authorization\_policy](#input\_skip\_kms\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all Event Streams database instances in the resource group to read the encryption key from the KMS instance. If set to false, pass in a value for the KMS instance in the `existing_kms_instance_guid` variable. In addition, no policy is created if var.kms\_encryption\_enabled is set to false. | `bool` | `false` | no |
154162
| <a name="input_storage_size"></a> [storage\_size](#input\_storage\_size) | Storage size of the Event Streams in GB. Applies only to Enterprise plan instances. Possible values: `2048`, `4096`, `6144`, `8192`, `10240`, `12288`. Storage capacity cannot be reduced after the instance is created. When the `throughput` input variable is set to `300`, storage size starts at 4096. When `throughput` is `450`, storage size starts starts at `6144`. | `number` | `"2048"` | no |
155163
| <a name="input_tags"></a> [tags](#input\_tags) | The list of tags associated with the Event Steams instance. | `list(string)` | `[]` | no |
156164
| <a name="input_throughput"></a> [throughput](#input\_throughput) | Throughput capacity in MB per second. Applies only to Enterprise plan instances. Possible values: `150`, `300`, `450`. | `number` | `"150"` | no |
@@ -167,6 +175,8 @@ You need the following permissions to run this module.
167175
| <a name="output_kafka_broker_version"></a> [kafka\_broker\_version](#output\_kafka\_broker\_version) | The Kafka version |
168176
| <a name="output_kafka_brokers_sasl"></a> [kafka\_brokers\_sasl](#output\_kafka\_brokers\_sasl) | (Array of Strings) Kafka brokers use for interacting with Kafka native API |
169177
| <a name="output_kafka_http_url"></a> [kafka\_http\_url](#output\_kafka\_http\_url) | The API endpoint to interact with Event Streams REST API |
178+
| <a name="output_mirroring_config_id"></a> [mirroring\_config\_id](#output\_mirroring\_config\_id) | The ID of the mirroring config in CRN format |
179+
| <a name="output_mirroring_topic_patterns"></a> [mirroring\_topic\_patterns](#output\_mirroring\_topic\_patterns) | Mirroring topic patterns |
170180
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | The service credentials JSON map. |
171181
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | The service credentials object. |
172182
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/fscloud/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The example uses the IBM Cloud Terraform provider to create the following infras
88
- An IAM authorization between all Event Stream instances in the given resource group and the Hyper Protect Crypto Services instance that is passed in.
99
- An Event Streams instance that is encrypted with the Hyper Protect Crypto Services root key that is passed in.
1010
- A sample virtual private cloud (VPC).
11-
- A context-based restriction (CBR) rule to only allow Event Streams to be accessible from within the VPC.
11+
- A context-based restriction (CBR) rule to only allow Event Streams to be accessible from within the VPC and Schematics.
1212

1313
:exclamation: **Important:** In this example, only the Event Streams instance complies with the IBM Cloud Framework for Financial Services. Other parts of the infrastructure do not necessarily comply.
1414

examples/fscloud/main.tf

+57-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ resource "ibm_is_subnet" "testacc_subnet" {
3636
##############################################################################
3737
# Create CBR Zone
3838
##############################################################################
39-
module "cbr_zone" {
39+
module "cbr_vpc_zone" {
4040
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
4141
version = "1.29.0"
4242
name = "${var.prefix}-VPC-network-zone"
@@ -48,6 +48,21 @@ module "cbr_zone" {
4848
}]
4949
}
5050

51+
module "cbr_zone_schematics" {
52+
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
53+
version = "1.29.0"
54+
name = "${var.prefix}-schematics-zone"
55+
zone_description = "CBR Network zone containing Schematics"
56+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
57+
addresses = [{
58+
type = "serviceRef",
59+
ref = {
60+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
61+
service_name = "schematics"
62+
}
63+
}]
64+
}
65+
5166

5267
# #############################################################################
5368
# Events-streams-instance
@@ -63,6 +78,35 @@ module "event_streams" {
6378
topics = var.topics
6479
existing_kms_instance_guid = var.existing_kms_instance_guid
6580
metrics = ["topic", "partition", "consumers"]
81+
mirroring_topic_patterns = ["topic-1", "topic-2"]
82+
mirroring = {
83+
source_crn = var.event_streams_source_crn # Required for mirroring
84+
source_alias = "source-alias" # Required for mirroring
85+
target_alias = "target-alias" # Required for mirroring
86+
87+
# 'options' are optional. Valid values for 'type' are 'rename', 'none', or 'use_alias'.
88+
# If 'type' is set to 'rename', then 'rename' object must include the following fields: 'add_prefix', 'add_suffix', 'remove_prefix', and 'remove_suffix'.
89+
options = {
90+
topic_name_transform = {
91+
type = "rename"
92+
rename = {
93+
add_prefix = "add_prefix"
94+
add_suffix = "add_suffix"
95+
remove_prefix = "remove_prefix"
96+
remove_suffix = "remove_suffix"
97+
}
98+
}
99+
group_id_transform = {
100+
type = "rename"
101+
rename = {
102+
add_prefix = "add_prefix"
103+
add_suffix = "add_suffix"
104+
remove_prefix = "remove_prefix"
105+
remove_suffix = "remove_suffix"
106+
}
107+
}
108+
}
109+
}
66110
quotas = [
67111
{
68112
"entity" = "iam-ServiceId-00000000-0000-0000-0000-000000000000",
@@ -78,7 +122,7 @@ module "event_streams" {
78122
}
79123
cbr_rules = [
80124
{
81-
description = "${var.prefix}-event stream access only from vpc"
125+
description = "${var.prefix}-event streams access from vpc and schematics"
82126
enforcement_mode = "enabled"
83127
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
84128
rule_contexts = [{
@@ -89,7 +133,17 @@ module "event_streams" {
89133
},
90134
{
91135
name = "networkZoneId"
92-
value = module.cbr_zone.zone_id
136+
value = module.cbr_vpc_zone.zone_id
137+
}]
138+
}, {
139+
attributes = [
140+
{
141+
"name" : "endpointType",
142+
"value" : "private"
143+
},
144+
{
145+
name = "networkZoneId"
146+
value = module.cbr_zone_schematics.zone_id
93147
}]
94148
}]
95149
}

examples/fscloud/outputs.tf

+10
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,13 @@ output "service_credentials_object" {
4343
value = module.event_streams.service_credentials_object
4444
sensitive = true
4545
}
46+
47+
output "mirroring_config_id" {
48+
description = "The ID of the mirroring config in CRN format"
49+
value = module.event_streams.mirroring_config_id
50+
}
51+
52+
output "mirroring_topic_patterns" {
53+
description = "Mirroring topic patterns"
54+
value = module.event_streams.mirroring_topic_patterns
55+
}

examples/fscloud/provider.tf

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
provider "ibm" {
22
ibmcloud_api_key = var.ibmcloud_api_key
33
region = var.region
4+
visibility = "private"
45
}

examples/fscloud/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ variable "kms_key_crn" {
6363
type = string
6464
description = "The root key CRN of a Hyper Protect Crypto Service (HPCS) that you want to use for disk encryption. See https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs&interface=ui for more information on integrating HPCS with Event Streams instance."
6565
}
66+
67+
variable "event_streams_source_crn" {
68+
type = string
69+
description = "Source cluster CRN as a string to create mirroring instance."
70+
}

0 commit comments

Comments
 (0)