Skip to content

Commit b83056d

Browse files
authored
feat: Added FScloud submodule (#126)
1 parent 8ea4165 commit b83056d

File tree

20 files changed

+528
-30
lines changed

20 files changed

+528
-30
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ A module to create IBM Cloud Event Notifications.
1010
<!-- BEGIN OVERVIEW HOOK -->
1111
## Overview
1212
* [terraform-ibm-event-notifications](#terraform-ibm-event-notifications)
13+
* [Submodules](./modules)
14+
* [fscloud](./modules/fscloud)
1315
* [Examples](./examples)
16+
* [ Financial Services Cloud profile example](./examples/fscloud)
1417
* [Basic example](./examples/basic)
1518
* [Complete example with BYOK encryption and CBR rules](./examples/complete)
1619
* [Contributing](#contributing)
@@ -91,8 +94,7 @@ To create service credentials, access to Event Notifications and access to call
9194
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> }))</pre> | `[]` | no |
9295
| <a name="input_existing_kms_instance_crn"></a> [existing\_kms\_instance\_crn](#input\_existing\_kms\_instance\_crn) | The CRN of the Hyper Protect Crypto Services or Key Protect instance. Required only if var.kms\_encryption\_enabled is set to true | `string` | `null` | no |
9396
| <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 Event Notification. If set to false, the data is encrypted by using randomly generated keys. For more info on Managing Encryption, see https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-en-managing-encryption | `bool` | `false` | no |
94-
| <a name="input_kms_endpoint"></a> [kms\_endpoint](#input\_kms\_endpoint) | The KMS endpoint to use when configuring KMS encryption. Must be private or public. | `string` | `"public"` | no |
95-
| <a name="input_kms_region"></a> [kms\_region](#input\_kms\_region) | The region where KMS instance exists if using KMS encryption. | `string` | `"us-south"` | no |
97+
| <a name="input_kms_endpoint_url"></a> [kms\_endpoint\_url](#input\_kms\_endpoint\_url) | The KMS endpoint URL to use when configuring KMS encryption. HPCS endpoint URL format- https://api.private.<REGION>.hs-crypto.cloud.ibm.com:<port> and KP endpoint URL format- https://<REGION>.kms.cloud.ibm.com | `string` | `null` | no |
9698
| <a name="input_name"></a> [name](#input\_name) | The name to give the IBM Event Notification instance created by this module. | `string` | n/a | yes |
9799
| <a name="input_plan"></a> [plan](#input\_plan) | Plan for the event notification instance : lite or standard | `string` | `"standard"` | no |
98100
| <a name="input_region"></a> [region](#input\_region) | IBM Cloud region where event notification will be created, supported regions are: us-south (Dallas), eu-gb (London), eu-de (Frankfurt), au-syd (Sydney), eu-es (Madrid) | `string` | `"us-south"` | no |
@@ -108,6 +110,7 @@ To create service credentials, access to Event Notifications and access to call
108110
| Name | Description |
109111
|------|-------------|
110112
| <a name="output_crn"></a> [crn](#output\_crn) | Event Notification crn |
113+
| <a name="output_event_notification_instance_name"></a> [event\_notification\_instance\_name](#output\_event\_notification\_instance\_name) | Event Notification name |
111114
| <a name="output_guid"></a> [guid](#output\_guid) | Event Notification guid |
112115
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | Service credentials json map |
113116
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | Service credentials object |

cra-config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# More info about this file at https://github.com/terraform-ibm-modules/common-pipeline-assets/blob/main/.github/workflows/terraform-test-pipeline.md#cra-config-yaml
22
version: "v1"
33
CRA_TARGETS:
4-
- CRA_TARGET: "examples/basic" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
4+
- CRA_TARGET: "examples/fscloud" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
55
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json" # CRA Ignore file to use. If not provided, it checks the repo root directory for `cra-tf-validate-ignore-rules.json`
6+
CRA_ENVIRONMENT_VARIABLES:
7+
TF_VAR_prefix: "cra-sap"
8+
TF_VAR_existing_kms_instance_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9::"
9+
TF_VAR_root_key_id: "76170fae-4e0c-48c3-8ebe-326059ebb533"
10+
TF_VAR_kms_endpoint_url: "https://api.private.us-south.hs-crypto.cloud.ibm.com:8992"
11+
12+
613
# CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
714
# TF_VAR_sample: "sample value"
815
# TF_VAR_other: "another value"

examples/basic/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# Outputs
33
##############################################################################
44

5+
output "event_notification_instance_name" {
6+
description = "Event Notification name"
7+
value = module.event_notification.event_notification_instance_name
8+
}
59
output "resource_group_name" {
610
description = "Resource group name"
711
value = module.resource_group.resource_group_name

examples/complete/main.tf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ locals {
2020
}
2121
module "key_protect_all_inclusive" {
2222
source = "terraform-ibm-modules/key-protect-all-inclusive/ibm"
23-
version = "4.4.2"
23+
version = "4.6.0"
2424
resource_group_id = module.resource_group.resource_group_id
2525
region = var.region
2626
key_protect_instance_name = "${var.prefix}-kp"
2727
resource_tags = var.resource_tags
28-
key_map = {
29-
(local.key_ring_name) = [local.key_name]
30-
}
28+
keys = [{
29+
key_ring_name = "en-key-ring"
30+
keys = [{
31+
key_name = "${var.prefix}-en"
32+
}]
33+
}]
3134
}
3235

3336
##############################################################################
@@ -77,11 +80,11 @@ module "event_notification" {
7780
kms_encryption_enabled = true
7881
existing_kms_instance_crn = module.key_protect_all_inclusive.key_protect_id
7982
root_key_id = module.key_protect_all_inclusive.keys["${local.key_ring_name}.${local.key_name}"].key_id
83+
kms_endpoint_url = module.key_protect_all_inclusive.kp_public_endpoint
8084
tags = var.resource_tags
8185
service_endpoints = "public"
8286
service_credential_names = var.service_credential_names
8387
region = var.region
84-
kms_region = var.region
8588
cbr_rules = [
8689
{
8790
description = "${var.prefix}-event notification access only from vpc"

examples/complete/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ output "resource_group_id" {
1212
value = module.resource_group.resource_group_id
1313
}
1414

15+
output "event_notification_instance_name" {
16+
description = "Event Notification name"
17+
value = module.event_notification.event_notification_instance_name
18+
}
19+
1520
output "crn" {
1621
description = "Event notification instance crn"
1722
value = module.event_notification.crn

examples/fscloud/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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-notifications/tree/main/modules/fscloud) to deploy an instance of Event Notification.
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 Notification instances in the given resource group and the KMS instance that is passed in.
9+
- An Event Notification instance that is encrypted with the KMS root key that is passed in.
10+
- A sample virtual private cloud (VPC).
11+
- A context-based restriction (CBR) rule to only allow Event Notification to be accessible from within the VPC.
12+
13+
:exclamation: **Important:** In this example, only the Event Notification 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 KMS instance and root key available in the region that you want to deploy your Event Notification instance to.
18+
- To ensure compliance with FSCloud standards, it is required to use HPCS only.

examples/fscloud/main.tf

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
##############################################################################
2+
# Resource group
3+
##############################################################################
4+
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.1.4"
8+
# if an existing resource group is not set (null) create a new one using prefix
9+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
10+
existing_resource_group_name = var.resource_group
11+
}
12+
13+
##############################################################################
14+
# Get Cloud Account ID
15+
##############################################################################
16+
17+
data "ibm_iam_account_settings" "iam_account_settings" {
18+
}
19+
20+
##############################################################################
21+
# VPC
22+
##############################################################################
23+
resource "ibm_is_vpc" "example_vpc" {
24+
name = "${var.prefix}-vpc"
25+
resource_group = module.resource_group.resource_group_id
26+
tags = var.resource_tags
27+
}
28+
29+
resource "ibm_is_subnet" "testacc_subnet" {
30+
name = "${var.prefix}-subnet"
31+
vpc = ibm_is_vpc.example_vpc.id
32+
zone = "${var.region}-1"
33+
total_ipv4_address_count = 256
34+
resource_group = module.resource_group.resource_group_id
35+
}
36+
37+
##############################################################################
38+
# Create CBR Zone
39+
##############################################################################
40+
41+
module "cbr_zone" {
42+
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
43+
version = "1.17.1"
44+
name = "${var.prefix}-VPC-network-zone"
45+
zone_description = "CBR Network zone representing VPC"
46+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
47+
addresses = [{
48+
type = "vpc",
49+
value = ibm_is_vpc.example_vpc.crn
50+
}]
51+
}
52+
53+
module "event_notification" {
54+
source = "../../modules/fscloud"
55+
resource_group_id = module.resource_group.resource_group_id
56+
name = "${var.prefix}-en-fs"
57+
existing_kms_instance_crn = var.existing_kms_instance_crn
58+
root_key_id = var.root_key_id
59+
kms_endpoint_url = var.kms_endpoint_url
60+
tags = var.resource_tags
61+
62+
# Map of name, role for service credentials that you want to create for the event notification
63+
service_credential_names = {
64+
"en_manager" : "Manager",
65+
"en_writer" : "Writer",
66+
"en_reader" : "Reader",
67+
"en_channel_editor" : "Channel Editor",
68+
"en_device_manager" : "Device Manager",
69+
"en_event_source_manager" : "Event Source Manager",
70+
"en_event_notifications_publisher" : "Event Notification Publisher",
71+
"en_status_reporter" : "Status Reporter",
72+
"en_email_sender" : "Email Sender",
73+
"en_custom_email_status_reporter" : "Custom Email Status Reporter",
74+
}
75+
region = var.region
76+
cbr_rules = [
77+
{
78+
description = "${var.prefix}-event notification access only from vpc"
79+
enforcement_mode = "report"
80+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
81+
rule_contexts = [{
82+
attributes = [
83+
{
84+
"name" : "endpointType",
85+
"value" : "private"
86+
},
87+
{
88+
name = "networkZoneId"
89+
value = module.cbr_zone.zone_id
90+
}]
91+
}]
92+
}
93+
]
94+
}

examples/fscloud/outputs.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 "event_notification_instance_name" {
16+
description = "Event Notification name"
17+
value = module.event_notification.event_notification_instance_name
18+
}
19+
20+
output "crn" {
21+
description = "Event notification instance crn"
22+
value = module.event_notification.crn
23+
}
24+
25+
output "guid" {
26+
description = "Event Notification guid"
27+
value = module.event_notification.guid
28+
}
29+
30+
output "service_credentials_json" {
31+
description = "Service credentials json map"
32+
value = module.event_notification.service_credentials_json
33+
sensitive = true
34+
}
35+
36+
output "service_credentials_object" {
37+
description = "Service credentials json object"
38+
value = module.event_notification.service_credentials_object
39+
sensitive = true
40+
}

examples/fscloud/provider.tf

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

examples/fscloud/variables.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
##############################################################################
2+
# Input Variables
3+
##############################################################################
4+
5+
variable "ibmcloud_api_key" {
6+
type = string
7+
description = "The IBM Cloud API Key"
8+
sensitive = true
9+
}
10+
11+
variable "resource_group" {
12+
type = string
13+
description = "The name of an existing resource group to provision resources in to. If not set a new resource group will be created using the prefix variable"
14+
default = null
15+
}
16+
17+
variable "prefix" {
18+
type = string
19+
description = "Prefix to append to all resources created by this example"
20+
}
21+
22+
variable "resource_tags" {
23+
type = list(string)
24+
description = "Optional list of tags to be added to created resources"
25+
default = []
26+
}
27+
28+
variable "region" {
29+
type = string
30+
description = "Region to provision all resources created by this example, Event Notifications supported regions are: us-south (Dallas), eu-gb (London), eu-de (Frankfurt), au-syd (Sydney), eu-es (Madrid)"
31+
default = "us-south"
32+
}
33+
34+
variable "existing_kms_instance_crn" {
35+
description = "The CRN of the Hyper Protect Crypto Services. To ensure compliance with FSCloud standards, it is required to use HPCS only"
36+
type = string
37+
}
38+
39+
variable "root_key_id" {
40+
type = string
41+
description = "The Key ID of a root key, existing in the KMS instance passed in var.existing_kms_instance_crn, which will be used to encrypt the data encryption keys (DEKs) which are then used to encrypt the data."
42+
}
43+
44+
variable "kms_endpoint_url" {
45+
description = "The KMS endpoint URL to use when configuring KMS encryption."
46+
type = string
47+
}

0 commit comments

Comments
 (0)