Skip to content

Commit c5f775b

Browse files
Merge branch 'main' into issue-10936
2 parents 4e058b7 + 5315c86 commit c5f775b

File tree

14 files changed

+321
-21
lines changed

14 files changed

+321
-21
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ This module implements IBM Event Streams for IBM Cloud with topics, partitions,
1212

1313
The Event Streams service supports payload data encryption that uses a root key CRN of a key management service, such as Key Protect or Hyper Protect Crypto Services. You specify the root key CRN with the `kms_key_crn` input. For more information, see [Managing encryption in Event Streams](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-managing_encryption).
1414

15-
Before you run the module, configure an authorization policy to allow the Event Streams service to access the key management service instance with the reader role. For more information, see [Using authorizations to grant access between services](https://cloud.ibm.com/docs/account?topic=account-serviceauth).
16-
17-
You can't manage the policy in the same Terraform state file as the Event Streams service instance. When you issue a `terraform destroy` command, the instance is only soft deleted and remains as a reclamation resource for a while to support recovery (reclamation). An authorization policy must exist when the instance is hard deleted or reclaimed or else the unregistration of the instance from the root key fails on the backend. If the policy doesn't exist, the only way to unregister the instance, which is a requirement for deletion of the root key, is by opening a support case. For more information, see [Using a customer-managed key](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-managing_encryption#using_encryption).
18-
1915
<!-- Below content is automatically populated via pre-commit hook -->
2016
<!-- BEGIN OVERVIEW HOOK -->
2117
## Overview
@@ -25,6 +21,7 @@ You can't manage the policy in the same Terraform state file as the Event Stream
2521
* [Examples](./examples)
2622
* [Basic example](./examples/basic)
2723
* [Complete example with topics and schema creation.](./examples/complete)
24+
* [Financial Services Cloud profile example](./examples/fscloud)
2825
* [Contributing](#contributing)
2926
<!-- END OVERVIEW HOOK -->
3027

@@ -110,6 +107,7 @@ You need the following permissions to run this module.
110107
|------|---------|
111108
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
112109
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.65.0, <2.0.0 |
110+
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1 |
113111

114112
### Modules
115113

@@ -123,8 +121,10 @@ You need the following permissions to run this module.
123121
|------|------|
124122
| [ibm_event_streams_schema.es_schema](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_schema) | resource |
125123
| [ibm_event_streams_topic.es_topic](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/event_streams_topic) | resource |
124+
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
126125
| [ibm_resource_instance.es_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
127126
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
127+
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
128128

129129
### Inputs
130130

@@ -134,13 +134,16 @@ You need the following permissions to run this module.
134134
| <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 |
135135
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | The timeout value for deleting an Event Streams instance. | `string` | `"15m"` | no |
136136
| <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 |
137-
| <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. Configure an authorization policy to allow the Event Streams service to access the key management service instance with the reader role ([Learn more](https://cloud.ibm.com/docs/account?topic=account-serviceauth)). You can't manage the policy in the same Terraform state file as the Event Streams service instance ([Learn more](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-managing_encryption#using\_encryption)). | `string` | `null` | no |
137+
| <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 |
138+
| <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 |
139+
| <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 |
138140
| <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 |
139141
| <a name="input_region"></a> [region](#input\_region) | The region where the Event Streams are created. | `string` | `"us-south"` | no |
140142
| <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 |
141143
| <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 |
142144
| <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 Notifications streams. | `map(string)` | `{}` | no |
143145
| <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 |
146+
| <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 |
144147
| <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 |
145148
| <a name="input_tags"></a> [tags](#input\_tags) | The list of tags associated with the Event Steams instance. | `list(string)` | `[]` | no |
146149
| <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 |

examples/fscloud/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Financial Services Cloud profile example
2+
3+
An end-to-end example that uses the [Profile for IBM Cloud Framework for Financial Services](https://github.com/terraform-ibm-modules/terraform-ibm-event-streams/tree/main/modules/fscloud) to deploy an instance of Event Streams.
4+
5+
The example uses the IBM Cloud Terraform provider to create the following infrastructure:
6+
7+
- A resource group, if one is not passed in.
8+
- An IAM authorization between all Event Stream instances in the given resource group and the Hyper Protect Crypto Services instance that is passed in.
9+
- An Event Streams instance that is encrypted with the Hyper Protect Crypto Services root key that is passed in.
10+
- 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.
12+
13+
: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.
14+
15+
## Before you begin
16+
17+
- You need a Hyper Protect Crypto Services instance and root key available in the region that you want to deploy your Event Streams instance to.

examples/fscloud/main.tf

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
##############################################################################
2+
# Resource Group
3+
##############################################################################
4+
5+
module "resource_group" {
6+
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.1.6"
7+
# if an existing resource group is not set (null) create a new one using prefix
8+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
9+
existing_resource_group_name = var.resource_group
10+
}
11+
12+
##############################################################################
13+
# Get Cloud Account ID
14+
##############################################################################
15+
16+
data "ibm_iam_account_settings" "iam_account_settings" {
17+
}
18+
19+
##############################################################################
20+
# VPC
21+
##############################################################################
22+
resource "ibm_is_vpc" "example_vpc" {
23+
name = "${var.prefix}-vpc"
24+
resource_group = module.resource_group.resource_group_id
25+
tags = var.resource_tags
26+
}
27+
28+
resource "ibm_is_subnet" "testacc_subnet" {
29+
name = "${var.prefix}-subnet"
30+
vpc = ibm_is_vpc.example_vpc.id
31+
zone = "${var.region}-1"
32+
total_ipv4_address_count = 256
33+
resource_group = module.resource_group.resource_group_id
34+
}
35+
36+
##############################################################################
37+
# Create CBR Zone
38+
##############################################################################
39+
module "cbr_zone" {
40+
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
41+
version = "1.27.0"
42+
name = "${var.prefix}-VPC-network-zone"
43+
zone_description = "CBR Network zone representing VPC"
44+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
45+
addresses = [{
46+
type = "vpc", # to bind a specific vpc to the zone
47+
value = ibm_is_vpc.example_vpc.crn,
48+
}]
49+
}
50+
51+
52+
# #############################################################################
53+
# Events-streams-instance
54+
# #############################################################################
55+
56+
module "event_streams" {
57+
source = "../../modules/fscloud"
58+
resource_group_id = module.resource_group.resource_group_id
59+
es_name = "${var.prefix}-es-fs"
60+
kms_key_crn = var.kms_key_crn
61+
schemas = var.schemas
62+
tags = var.resource_tags
63+
topics = var.topics
64+
existing_kms_instance_guid = var.existing_kms_instance_guid
65+
cbr_rules = [
66+
{
67+
description = "${var.prefix}-event stream access only from vpc"
68+
enforcement_mode = "enabled"
69+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
70+
rule_contexts = [{
71+
attributes = [
72+
{
73+
"name" : "endpointType",
74+
"value" : "private"
75+
},
76+
{
77+
name = "networkZoneId"
78+
value = module.cbr_zone.zone_id
79+
}]
80+
}]
81+
}
82+
]
83+
}

examples/fscloud/outputs.tf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
##############################################################################
2+
# Outputs
3+
##############################################################################
4+
5+
output "resource_group_name" {
6+
description = "Resource group name"
7+
value = module.resource_group.resource_group_name
8+
}
9+
10+
output "resource_group_id" {
11+
description = "Resource group ID"
12+
value = module.resource_group.resource_group_id
13+
}
14+
15+
output "crn" {
16+
description = "Event Streams instance crn"
17+
value = module.event_streams.crn
18+
}
19+
20+
output "guid" {
21+
description = "Event Streams instance guid"
22+
value = module.event_streams.guid
23+
}
24+
25+
output "kafka_brokers_sasl" {
26+
description = "(Array of Strings) Kafka brokers use for interacting with Kafka native API"
27+
value = module.event_streams.kafka_brokers_sasl
28+
}
29+
30+
output "kafka_http_url" {
31+
description = "The API endpoint to interact with Event Streams REST API"
32+
value = module.event_streams.kafka_http_url
33+
}

examples/fscloud/provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "ibm" {
2+
ibmcloud_api_key = var.ibmcloud_api_key
3+
region = var.region
4+
}

examples/fscloud/variables.tf

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
variable "ibmcloud_api_key" {
2+
type = string
3+
description = "The IBM Cloud API Key"
4+
sensitive = true
5+
}
6+
7+
variable "region" {
8+
type = string
9+
description = "Region to provision all resources created by this example"
10+
default = "us-south"
11+
}
12+
13+
variable "prefix" {
14+
type = string
15+
description = "Prefix to append to all resources created by this example"
16+
default = "fs-cloud"
17+
}
18+
19+
variable "resource_group" {
20+
type = string
21+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
22+
default = null
23+
}
24+
25+
variable "resource_tags" {
26+
type = list(string)
27+
description = "List of tags associated with the Event Steams instance"
28+
default = []
29+
}
30+
31+
variable "schemas" {
32+
type = list(object(
33+
{
34+
schema_id = string
35+
schema = object({
36+
type = string
37+
name = string
38+
})
39+
}
40+
))
41+
description = "The list of schema object which contains schema id and format of the schema"
42+
default = []
43+
}
44+
45+
variable "topics" {
46+
type = list(object(
47+
{
48+
name = string
49+
partitions = number
50+
config = object({})
51+
}
52+
))
53+
description = "List of topics. For lite plan only one topic is allowed."
54+
default = []
55+
}
56+
57+
variable "existing_kms_instance_guid" {
58+
description = "The GUID of the Hyper Protect Crypto service in which the key specified in var.kms_key_crn is coming from"
59+
type = string
60+
}
61+
62+
variable "kms_key_crn" {
63+
type = string
64+
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."
65+
}

examples/fscloud/version.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.3.0"
3+
required_providers {
4+
# Use latest version of provider in non-basic examples to verify latest version works with module
5+
ibm = {
6+
source = "IBM-Cloud/ibm"
7+
version = ">= 1.56.1"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)