Skip to content

Commit d2b853d

Browse files
authored
feat: initial release (#52)
1 parent cd4777a commit d2b853d

File tree

17 files changed

+858
-108
lines changed

17 files changed

+858
-108
lines changed

README.md

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Event Notification module
2-
[![Incubating (Not yet consumable)](https://img.shields.io/badge/status-Incubating%20(Not%20yet%20consumable)-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
2+
[![Stable (With quality checks)](https://img.shields.io/badge/Status-Stable%20(With%20quality%20checks)-green)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
33
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
44
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-event-notifications?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-event-notifications/releases/latest)
55
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
@@ -12,76 +12,105 @@ A module to create IBM Cloud Event Notifications.
1212
* [terraform-ibm-event-notifications](#terraform-ibm-event-notifications)
1313
* [Examples](./examples)
1414
* [Basic example](./examples/basic)
15-
* [Complete example](./examples/complete)
15+
* [Complete example with BYOK encryption and CBR rules](./examples/complete)
1616
* [Contributing](#contributing)
1717
<!-- END OVERVIEW HOOK -->
1818

1919
## terraform-ibm-event-notifications
2020

2121
### Usage
2222

23-
<!--
24-
Add an example of the use of the module in the following code block.
25-
26-
Use real values instead of "var.<var_name>" or other placeholder values
27-
unless real values don't help users know what to change.
28-
-->
29-
3023
```hcl
31-
24+
module "event_notification" {
25+
source = "terraform-ibm-modules/event-notifications/ibm"
26+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
27+
resource_group_id = "a8cff104f1764e98aac9ab879198230a" # pragma: allowlist secret
28+
name = "event-notification"
29+
tags = ["dev", "qa"]
30+
plan = "lite"
31+
service_endpoints = "public"
32+
service_credential_names = {
33+
"en_manager" : "Manager",
34+
"en_writer" : "Writer",
35+
"en_reader" : "Reader",
36+
}
37+
}
3238
```
3339

3440
### Required IAM access policies
3541

36-
<!-- PERMISSIONS REQUIRED TO RUN MODULE
37-
If this module requires permissions, uncomment the following block and update
38-
the sample permissions, following the format.
39-
Replace the sample Account and IBM Cloud service names and roles with the
40-
information in the console at
41-
Manage > Access (IAM) > Access groups > Access policies.
42-
-->
43-
44-
<!--
4542
You need the following permissions to run this module.
4643

4744
- Account Management
48-
- **Sample Account Service** service
49-
- `Editor` platform access
50-
- `Manager` service access
51-
- IAM Services
52-
- **Sample Cloud Service** service
53-
- `Administrator` platform access
54-
-->
55-
56-
<!-- NO PERMISSIONS FOR MODULE
57-
If no permissions are required for the module, uncomment the following
58-
statement instead the previous block.
59-
-->
60-
61-
<!-- No permissions are needed to run this module.-->
62-
<!-- END MODULE HOOK -->
45+
- **Event Notification** service
46+
- Platform Management Roles
47+
- `Editor` platform role access
48+
49+
To create service credentials, access to Event Notifications and access to call the Event Notifications API, you need the following access.
50+
51+
- Service Access Roles
52+
- `Reader` - View Event Notifications instance data
53+
- `Writer` - View and edit an Event Notifications instance
54+
- `Channel Editor` - View, create, and delete Event Notifications subscriptions
55+
- `Manager` - View, edit, and delete data in an Event Notifications instance
56+
- `Service Configuration Reader` - Read services configuration for Governance management
57+
- `Event Source Manager` - Source integration with Event Notifications by using service to service authorization
58+
- `Event Notifications Publisher` - Create notification and view notifications count
59+
- `Device Manager` - Custom role to handle push device registration with the Event Notifications service
60+
6361
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6462
### Requirements
6563

6664
| Name | Version |
6765
|------|---------|
6866
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.6.0 |
67+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.56.1, < 2.0.0 |
68+
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1 |
6969

7070
### Modules
7171

72-
No modules.
72+
| Name | Source | Version |
73+
|------|--------|---------|
74+
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.15.1 |
7375

7476
### Resources
7577

76-
No resources.
78+
| Name | Type |
79+
|------|------|
80+
| [ibm_en_integration.en_kms_integration](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/en_integration) | resource |
81+
| [ibm_iam_authorization_policy.kms_policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
82+
| [ibm_resource_instance.en_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
83+
| [ibm_resource_key.service_credentials](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_key) | resource |
84+
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
85+
| [ibm_en_integrations.en_integrations](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/en_integrations) | data source |
7786

7887
### Inputs
7988

80-
No inputs.
89+
| Name | Description | Type | Default | Required |
90+
|------|-------------|------|---------|:--------:|
91+
| <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 |
92+
| <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 |
93+
| <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 |
96+
| <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 |
97+
| <a name="input_plan"></a> [plan](#input\_plan) | Plan for the event notification instance : lite or standard | `string` | `"standard"` | no |
98+
| <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 |
99+
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The resource group ID where the Event Notification instance will be created. | `string` | n/a | yes |
100+
| <a name="input_root_key_id"></a> [root\_key\_id](#input\_root\_key\_id) | 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. Required if var.kms\_encryption\_enabled is set to true. | `string` | `null` | no |
101+
| <a name="input_service_credential_names"></a> [service\_credential\_names](#input\_service\_credential\_names) | Map of name, role for service credentials that you want to create for the event notification | `map(string)` | `{}` | no |
102+
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | Specify whether you want to enable the public or both public and private service endpoints. Supported values are 'public' or 'public-and-private'. | `string` | `"public-and-private"` | no |
103+
| <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 Notification instances in the resource group to read the encryption key from the KMS instance. No policy is created if var.kms\_encryption\_enabled is set to false. | `bool` | `false` | no |
104+
| <a name="input_tags"></a> [tags](#input\_tags) | Optional list of tags to be added to the Event Notification instance | `list(string)` | `[]` | no |
81105

82106
### Outputs
83107

84-
No outputs.
108+
| Name | Description |
109+
|------|-------------|
110+
| <a name="output_crn"></a> [crn](#output\_crn) | Event Notification crn |
111+
| <a name="output_guid"></a> [guid](#output\_guid) | Event Notification guid |
112+
| <a name="output_service_credentials_json"></a> [service\_credentials\_json](#output\_service\_credentials\_json) | Service credentials json map |
113+
| <a name="output_service_credentials_object"></a> [service\_credentials\_object](#output\_service\_credentials\_object) | Service credentials object |
85114
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
86115

87116
<!-- BEGIN CONTRIBUTING HOOK -->

examples/basic/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Basic example
22

3-
<!-- There is a pre-commit hook that will take the title of each example add include it in the repos main README.md -->
4-
<!-- The text below should describe exactly what resources are provisioned / configured by the example -->
5-
63
An end-to-end basic example that will provision the following:
74
- A new resource group if one is not passed in.
8-
- A new Cloud Object Storage instance.
5+
- A new Event Notification lite instance.

examples/basic/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ module "resource_group" {
1111
}
1212

1313
##############################################################################
14-
# COS instance
14+
# Events-notification-instance
1515
##############################################################################
1616

17-
resource "ibm_resource_instance" "cos_instance" {
18-
name = "${var.prefix}-cos"
17+
module "event_notification" {
18+
source = "../../"
1919
resource_group_id = module.resource_group.resource_group_id
20-
service = "cloud-object-storage"
21-
plan = "standard"
22-
location = "global"
20+
name = "${var.prefix}-en"
2321
tags = var.resource_tags
22+
plan = "lite"
23+
service_endpoints = "public"
24+
region = var.region
2425
}

examples/basic/outputs.tf

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

5-
output "cos_instance_id" {
6-
description = "COS instance id"
7-
value = ibm_resource_instance.cos_instance.id
8-
}
9-
105
output "resource_group_name" {
116
description = "Resource group name"
127
value = module.resource_group.resource_group_name
@@ -16,3 +11,13 @@ output "resource_group_id" {
1611
description = "Resource group ID"
1712
value = module.resource_group.resource_group_id
1813
}
14+
15+
output "crn" {
16+
description = "Event notification instance crn"
17+
value = module.event_notification.crn
18+
}
19+
20+
output "guid" {
21+
description = "Event Notification guid"
22+
value = module.event_notification.guid
23+
}

examples/basic/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variable "ibmcloud_api_key" {
1010

1111
variable "region" {
1212
type = string
13-
description = "Region to provision all resources created by this example"
13+
description = "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)"
1414
default = "us-south"
1515
}
1616

examples/basic/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
required_providers {
77
ibm = {
88
source = "IBM-Cloud/ibm"
9-
version = "1.49.0"
9+
version = "1.56.1"
1010
}
1111
}
1212
}

examples/complete/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Complete example
1+
# Complete example with BYOK encryption and CBR rules
22

3-
<!-- There is a pre-commit hook that will take the title of each example add include it in the repos main README.md -->
4-
<!-- Add text below should describe exactly what resources are provisioned / configured by the example -->
3+
An end-to-end example that does the following:
4+
5+
- Create a new resource group if one is not passed in.
6+
- Create Key Protect instance with root key.
7+
- Create a new Event Notification instance with BYOK encryption.
8+
- Create a Virtual Private Cloud (VPC).
9+
- Create a context-based restriction (CBR) rule to only allow Event Notification to be accessible from within the VPC.
10+
- Create a service credentials for the Event Notification instance.

examples/complete/main.tf

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,103 @@
11
##############################################################################
2-
# Complete example
2+
# Resource group
33
##############################################################################
4+
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.1.0"
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+
# Key Protect All Inclusive
15+
##############################################################################
16+
17+
locals {
18+
key_ring_name = "en-key-ring"
19+
key_name = "${var.prefix}-en"
20+
}
21+
module "key_protect_all_inclusive" {
22+
source = "terraform-ibm-modules/key-protect-all-inclusive/ibm"
23+
version = "4.2.0"
24+
resource_group_id = module.resource_group.resource_group_id
25+
region = var.region
26+
key_protect_instance_name = "${var.prefix}-kp"
27+
resource_tags = var.resource_tags
28+
key_map = {
29+
(local.key_ring_name) = [local.key_name]
30+
}
31+
}
32+
33+
##############################################################################
34+
# Get Cloud Account ID
35+
##############################################################################
36+
37+
data "ibm_iam_account_settings" "iam_account_settings" {
38+
}
39+
40+
##############################################################################
41+
# VPC
42+
##############################################################################
43+
resource "ibm_is_vpc" "example_vpc" {
44+
name = "${var.prefix}-vpc"
45+
resource_group = module.resource_group.resource_group_id
46+
tags = var.resource_tags
47+
}
48+
49+
resource "ibm_is_subnet" "testacc_subnet" {
50+
name = "${var.prefix}-subnet"
51+
vpc = ibm_is_vpc.example_vpc.id
52+
zone = "${var.region}-1"
53+
total_ipv4_address_count = 256
54+
resource_group = module.resource_group.resource_group_id
55+
}
56+
57+
##############################################################################
58+
# Create CBR Zone
59+
##############################################################################
60+
61+
module "cbr_zone" {
62+
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
63+
version = "1.15.1"
64+
name = "${var.prefix}-VPC-network-zone"
65+
zone_description = "CBR Network zone representing VPC"
66+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
67+
addresses = [{
68+
type = "vpc",
69+
value = ibm_is_vpc.example_vpc.crn
70+
}]
71+
}
72+
73+
module "event_notification" {
74+
source = "../../"
75+
resource_group_id = module.resource_group.resource_group_id
76+
name = "${var.prefix}-en"
77+
kms_encryption_enabled = true
78+
existing_kms_instance_crn = module.key_protect_all_inclusive.key_protect_id
79+
root_key_id = module.key_protect_all_inclusive.keys["${local.key_ring_name}.${local.key_name}"].key_id
80+
tags = var.resource_tags
81+
service_endpoints = "public"
82+
service_credential_names = var.service_credential_names
83+
region = var.region
84+
kms_region = var.region
85+
cbr_rules = [
86+
{
87+
description = "${var.prefix}-event notification access only from vpc"
88+
enforcement_mode = "report"
89+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
90+
rule_contexts = [{
91+
attributes = [
92+
{
93+
"name" : "endpointType",
94+
"value" : "public"
95+
},
96+
{
97+
name = "networkZoneId"
98+
value = module.cbr_zone.zone_id
99+
}]
100+
}]
101+
}
102+
]
103+
}

examples/complete/outputs.tf

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,34 @@
22
# Outputs
33
##############################################################################
44

5-
output "region" {
6-
description = "The region all resources were provisioned in"
7-
value = var.region
5+
output "resource_group_name" {
6+
description = "Resource group name"
7+
value = module.resource_group.resource_group_name
88
}
99

10-
output "prefix" {
11-
description = "The prefix used to name all provisioned resources"
12-
value = var.prefix
10+
output "resource_group_id" {
11+
description = "Resource group ID"
12+
value = module.resource_group.resource_group_id
1313
}
1414

15-
output "resource_group_name" {
16-
description = "The name of the resource group used"
17-
value = var.resource_group
15+
output "crn" {
16+
description = "Event notification instance crn"
17+
value = module.event_notification.crn
18+
}
19+
20+
output "guid" {
21+
description = "Event Notification guid"
22+
value = module.event_notification.guid
23+
}
24+
25+
output "service_credentials_json" {
26+
description = "Service credentials json map"
27+
value = module.event_notification.service_credentials_json
28+
sensitive = true
1829
}
1930

20-
output "resource_tags" {
21-
description = "List of resource tags"
22-
value = var.resource_tags
31+
output "service_credentials_object" {
32+
description = "Service credentials json object"
33+
value = module.event_notification.service_credentials_object
34+
sensitive = true
2335
}

0 commit comments

Comments
 (0)