Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added mirroring support #327

Merged
merged 34 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fc93ca8
feat: added mirroring support
Ak-sky Oct 29, 2024
87a2643
feat: added mirroring support
Ak-sky Oct 29, 2024
a2a6373
feat: added mirroring support
Ak-sky Oct 29, 2024
c658f17
added mirroring test
Ak-sky Oct 29, 2024
62a3e2d
Merge branch 'main' into mirror
Ak-sky Nov 5, 2024
ed32059
Merge remote-tracking branch 'origin/main' into mirror
Ak-sky Nov 13, 2024
087f175
Merge branch 'main' into mirror
Ak-sky Nov 18, 2024
e966f58
added mirroring feat
Ak-sky Nov 19, 2024
31dbb39
added mirroring feat
Ak-sky Nov 19, 2024
05b231e
added mirroring feat
Ak-sky Nov 19, 2024
f8c66a9
minor fixes
Ak-sky Nov 19, 2024
f7a54d7
minor fixes
Ak-sky Nov 19, 2024
853574f
minor fixes
Ak-sky Nov 19, 2024
3f1117b
removed mirroring ex
Ak-sky Nov 20, 2024
cdbd699
resolved conflicts
Ak-sky Nov 20, 2024
e3b4b70
added tests
Ak-sky Nov 20, 2024
8843366
minor fixes
Ak-sky Nov 21, 2024
a51810c
fix auth policy var exposure
Ak-sky Nov 21, 2024
38becf9
minor fixes
Ak-sky Nov 21, 2024
1016854
updated mirroring variable
Ak-sky Nov 21, 2024
88dc2e1
updated mirroring variable description
Ak-sky Nov 21, 2024
899fcba
updated mirroring variable description
Ak-sky Nov 21, 2024
122ac00
minor fixes
Ak-sky Nov 22, 2024
2b02a8a
minor fixes
Ak-sky Nov 22, 2024
4639bc8
auth policy fixes
Ak-sky Nov 22, 2024
45c7db6
auth policy fixes
Ak-sky Nov 22, 2024
849c925
Merge remote-tracking branch 'origin/main' into mirror
Ak-sky Nov 24, 2024
63e6d15
updated test
Ak-sky Nov 24, 2024
8513199
fscloud in schematics
Ak-sky Nov 26, 2024
8849900
updated mirroring variable in fscloud
Ak-sky Nov 26, 2024
1f2dae1
addressed review comments
Ak-sky Nov 29, 2024
45b566b
addressed review comments
Ak-sky Nov 29, 2024
8a578f0
addressed review comments
Ak-sky Nov 29, 2024
3ceb859
addressed review comments
Ak-sky Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,25 @@ You need the following permissions to run this module.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.29.0 |
| <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 |

### Resources

| Name | Type |
|------|------|
| [ibm_event_streams_mirroring_config.es_mirroring_config](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_mirroring_config) | resource |
| [ibm_event_streams_quota.eventstreams_quotas](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_quota) | resource |
| [ibm_event_streams_schema.es_schema](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_schema) | resource |
| [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 |
| [ibm_event_streams_topic.es_topic](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_topic) | resource |
| [ibm_iam_authorization_policy.es_s2s_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
| [ibm_resource_instance.es_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
| [ibm_resource_tag.es_access_tag](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_tag) | resource |
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [time_sleep.wait_for_es_s2s_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [time_sleep.wait_for_kms_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |

### Inputs

Expand All @@ -138,10 +143,12 @@ You need the following permissions to run this module.
| <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 |
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | The timeout value for deleting an Event Streams instance. | `string` | `"15m"` | no |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
Expand All @@ -150,7 +157,8 @@ You need the following permissions to run this module.
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_tags"></a> [tags](#input\_tags) | The list of tags associated with the Event Steams instance. | `list(string)` | `[]` | no |
| <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 |
Expand All @@ -167,6 +175,8 @@ You need the following permissions to run this module.
| <a name="output_kafka_broker_version"></a> [kafka\_broker\_version](#output\_kafka\_broker\_version) | The Kafka version |
| <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 |
| <a name="output_kafka_http_url"></a> [kafka\_http\_url](#output\_kafka\_http\_url) | The API endpoint to interact with Event Streams REST API |
| <a name="output_mirroring_config_id"></a> [mirroring\_config\_id](#output\_mirroring\_config\_id) | The ID of the mirroring config in CRN format |
| <a name="output_mirroring_topic_patterns"></a> [mirroring\_topic\_patterns](#output\_mirroring\_topic\_patterns) | Mirroring topic patterns |
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | The service credentials JSON map. |
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | The service credentials object. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
2 changes: 1 addition & 1 deletion examples/fscloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The example uses the IBM Cloud Terraform provider to create the following infras
- An IAM authorization between all Event Stream instances in the given resource group and the Hyper Protect Crypto Services instance that is passed in.
- An Event Streams instance that is encrypted with the Hyper Protect Crypto Services root key that is passed in.
- A sample virtual private cloud (VPC).
- A context-based restriction (CBR) rule to only allow Event Streams to be accessible from within the VPC.
- A context-based restriction (CBR) rule to only allow Event Streams to be accessible from within the VPC and Schematics.

: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.

Expand Down
60 changes: 57 additions & 3 deletions examples/fscloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "ibm_is_subnet" "testacc_subnet" {
##############################################################################
# Create CBR Zone
##############################################################################
module "cbr_zone" {
module "cbr_vpc_zone" {
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
version = "1.29.0"
name = "${var.prefix}-VPC-network-zone"
Expand All @@ -48,6 +48,21 @@ module "cbr_zone" {
}]
}

module "cbr_zone_schematics" {
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
version = "1.29.0"
name = "${var.prefix}-schematics-zone"
zone_description = "CBR Network zone containing Schematics"
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
addresses = [{
type = "serviceRef",
ref = {
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
service_name = "schematics"
}
}]
}


# #############################################################################
# Events-streams-instance
Expand All @@ -63,6 +78,35 @@ module "event_streams" {
topics = var.topics
existing_kms_instance_guid = var.existing_kms_instance_guid
metrics = ["topic", "partition", "consumers"]
mirroring_topic_patterns = ["topic-1", "topic-2"]
mirroring = {
source_crn = var.event_streams_source_crn # Required for mirroring
source_alias = "source-alias" # Required for mirroring
target_alias = "target-alias" # Required for mirroring

# 'options' are optional. Valid values for 'type' are 'rename', 'none', or 'use_alias'.
# If 'type' is set to 'rename', then 'rename' object must include the following fields: 'add_prefix', 'add_suffix', 'remove_prefix', and 'remove_suffix'.
options = {
topic_name_transform = {
type = "rename"
rename = {
add_prefix = "add_prefix"
add_suffix = "add_suffix"
remove_prefix = "remove_prefix"
remove_suffix = "remove_suffix"
}
}
group_id_transform = {
type = "rename"
rename = {
add_prefix = "add_prefix"
add_suffix = "add_suffix"
remove_prefix = "remove_prefix"
remove_suffix = "remove_suffix"
}
}
}
}
quotas = [
{
"entity" = "iam-ServiceId-00000000-0000-0000-0000-000000000000",
Expand All @@ -78,7 +122,7 @@ module "event_streams" {
}
cbr_rules = [
{
description = "${var.prefix}-event stream access only from vpc"
description = "${var.prefix}-event streams access from vpc and schematics"
enforcement_mode = "enabled"
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
rule_contexts = [{
Expand All @@ -89,7 +133,17 @@ module "event_streams" {
},
{
name = "networkZoneId"
value = module.cbr_zone.zone_id
value = module.cbr_vpc_zone.zone_id
}]
}, {
attributes = [
{
"name" : "endpointType",
"value" : "private"
},
{
name = "networkZoneId"
value = module.cbr_zone_schematics.zone_id
}]
}]
}
Expand Down
10 changes: 10 additions & 0 deletions examples/fscloud/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ output "service_credentials_object" {
value = module.event_streams.service_credentials_object
sensitive = true
}

output "mirroring_config_id" {
description = "The ID of the mirroring config in CRN format"
value = module.event_streams.mirroring_config_id
}

output "mirroring_topic_patterns" {
description = "Mirroring topic patterns"
value = module.event_streams.mirroring_topic_patterns
}
1 change: 1 addition & 0 deletions examples/fscloud/provider.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
visibility = "private"
}
5 changes: 5 additions & 0 deletions examples/fscloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ variable "kms_key_crn" {
type = string
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."
}

Ak-sky marked this conversation as resolved.
Show resolved Hide resolved
variable "event_streams_source_crn" {
type = string
description = "Source cluster CRN as a string to create mirroring instance."
}
Loading