Skip to content

Commit 5c6d0cb

Browse files
feat: adds the ability to pass CBR rules in DA. It adds a new variable cbr_rules in DA variables. (#371)
1 parent dac9cf1 commit 5c6d0cb

File tree

8 files changed

+97
-2
lines changed

8 files changed

+97
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ To create service credentials, access the Event Notifications service, and acces
9696

9797
| Name | Description | Type | Default | Required |
9898
|------|-------------|------|---------|:--------:|
99-
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restrictions 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 |
99+
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restrictions 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/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
100100
| <a name="input_cos_bucket_name"></a> [cos\_bucket\_name](#input\_cos\_bucket\_name) | The name of an existing IBM Cloud Object Storage bucket which will be used for storage of failed delivery events. Required if `cos_integration_enabled` is set to true. | `string` | `null` | no |
101101
| <a name="input_cos_endpoint"></a> [cos\_endpoint](#input\_cos\_endpoint) | The endpoint URL for your bucket region. For more information, see https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints. Required if `cos_integration_enabled` is set to true. | `string` | `null` | no |
102102
| <a name="input_cos_instance_id"></a> [cos\_instance\_id](#input\_cos\_instance\_id) | The ID of the IBM Cloud Object Storage instance in which the bucket that is defined in the `cos_bucket_name` variable exists. Required if `cos_integration_enabled` is set to true. | `string` | `null` | no |

ibm_catalog.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@
291291
},
292292
{
293293
"key": "existing_en_instance_crn"
294+
},
295+
{
296+
"key":"cbr_rules"
294297
}
295298
],
296299
"iam_permissions": [

modules/fscloud/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ No resources.
8080

8181
| Name | Description | Type | Default | Required |
8282
|------|-------------|------|---------|:--------:|
83-
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restrictions 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 |
83+
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restrictions 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/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
8484
| <a name="input_cos_bucket_name"></a> [cos\_bucket\_name](#input\_cos\_bucket\_name) | The name of an existing Object Storage bucket to use for the storage of failed delivery events. | `string` | `null` | no |
8585
| <a name="input_cos_endpoint"></a> [cos\_endpoint](#input\_cos\_endpoint) | The endpoint URL for your bucket region. Required if `cos_integration_enabled` is set to `true`. [Learn more](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints). | `string` | `null` | no |
8686
| <a name="input_cos_instance_id"></a> [cos\_instance\_id](#input\_cos\_instance\_id) | The ID of the IBM Cloud Object Storage instance in which the bucket that is defined in the `cos_bucket_name` variable exists. Required if `cos_integration_enabled` is set to true. | `string` | `null` | no |

modules/fscloud/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ variable "cbr_rules" {
6161
value = string
6262
}))) }))
6363
enforcement_mode = string
64+
operations = optional(list(object({
65+
api_types = list(object({
66+
api_type_id = string
67+
}))
68+
})))
6469
}))
6570
description = "The list of context-based restrictions rules to create."
6671
default = []

solutions/standard/DA-cbr_rules.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Configuring complex inputs for Event Notifications in IBM Cloud projects
2+
3+
Several optional input variables in the IBM Cloud [Event Notifications deployable architecture](https://cloud.ibm.com/catalog#deployable_architecture) use complex object types. You specify these inputs when you configure deployable architecture.
4+
5+
* Context-Based Restrictions Rules (`cbr_rules`)
6+
7+
8+
## Rules For Context-Based Restrictions <a name="cbr_rules"></a>
9+
10+
The `cbr_rules` input variable allows you to provide a rule for the target service to enforce access restrictions for the service based on the context of access requests. Contexts are criteria that include the network location of access requests, the endpoint type from where the request is sent, etc.
11+
12+
- Variable name: `cbr_rules`.
13+
- Type: A list of objects. Allows only one object representing a rule for the target service
14+
- Default value: An empty list (`[]`).
15+
16+
### Options for cbr_rules
17+
18+
- `description` (required): The description of the rule to create.
19+
- `account_id` (required): The IBM Cloud Account ID
20+
- `rule_contexts` (required): (List) The contexts the rule applies to
21+
- `attributes` (optional): (List) Individual context attributes
22+
- `name` (required): The attribute name.
23+
- `value`(required): The attribute value.
24+
25+
- `enforcement_mode` (required): The rule enforcement mode can have the following values:
26+
- `enabled` - The restrictions are enforced and reported. This is the default.
27+
- `disabled` - The restrictions are disabled. Nothing is enforced or reported.
28+
- `report` - The restrictions are evaluated and reported, but not enforced.
29+
- `operations` (optional): The operations this rule applies to
30+
- `api_types`(required): (List) The API types this rule applies to.
31+
- `api_type_id`(required):The API type ID
32+
33+
34+
### Example Rule For Context-Based Restrictions Configuration
35+
36+
```hcl
37+
cbr_rules = [
38+
{
39+
description = "Event Notifications can be accessed from xyz"
40+
account_id = "defc0df06b644a9cabc6e44f55b3880s."
41+
rule_contexts= [{
42+
attributes = [
43+
{
44+
"name" : "endpointType",
45+
"value" : "private"
46+
},
47+
{
48+
name = "networkZoneId"
49+
value = "93a51a1debe2674193217209601dde6f" # pragma: allowlist secret
50+
}
51+
]
52+
}
53+
]
54+
enforcement_mode = "enabled"
55+
operations = [{
56+
api_types = [{
57+
api_type_id = "crn:v1:bluemix:public:context-based-restrictions::::api-type:"
58+
}]
59+
}]
60+
}
61+
]
62+
```

solutions/standard/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ module "event_notifications" {
321321
cos_instance_id = var.existing_cos_instance_crn != null ? var.existing_cos_instance_crn : module.cos[0].cos_instance_crn
322322
skip_en_cos_auth_policy = var.skip_en_cos_auth_policy
323323
cos_endpoint = local.cos_endpoint
324+
cbr_rules = var.cbr_rules
324325
}
325326

326327
########################################################################################################################

solutions/standard/variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,22 @@ variable "skip_en_sm_auth_policy" {
343343
default = false
344344
description = "Whether an IAM authorization policy is created for Secrets Manager instance to create a service credential secrets for Event Notification.If set to false, the Secrets Manager instance passed by the user is granted the Key Manager access to the Event Notifications instance created by the Deployable Architecture. Set to `true` to use an existing policy. The value of this is ignored if any value for 'existing_secrets_manager_instance_crn' is not passed."
345345
}
346+
variable "cbr_rules" {
347+
type = list(object({
348+
description = string
349+
account_id = string
350+
rule_contexts = list(object({
351+
attributes = optional(list(object({
352+
name = string
353+
value = string
354+
}))) }))
355+
enforcement_mode = string
356+
operations = optional(list(object({
357+
api_types = list(object({
358+
api_type_id = string
359+
}))
360+
})))
361+
}))
362+
description = "The list of context-based restrictions rules to create. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-event-notifications/tree/main/solutions/standard/DA-cbr_rules.md)"
363+
default = []
364+
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ variable "cbr_rules" {
8181
value = string
8282
}))) }))
8383
enforcement_mode = string
84+
operations = optional(list(object({
85+
api_types = list(object({
86+
api_type_id = string
87+
}))
88+
})))
8489
}))
8590
description = "The list of context-based restrictions rules to create."
8691
default = []

0 commit comments

Comments
 (0)