Skip to content

Commit b6c49cc

Browse files
feat: enables the ability to use CBR rules in DA (#263)
Updates: - enables the ability to use CBR rules in DA - adds a new variable cbr_rules in DA variables - updates `cbr_rule` variable in root module to include `operations`
1 parent a58d373 commit b6c49cc

File tree

8 files changed

+102
-2
lines changed

8 files changed

+102
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ You need the following permissions to run this module.
9494
| Name | Description | Type | Default | Required |
9595
|------|-------------|------|---------|:--------:|
9696
| <a name="input_allowed_network"></a> [allowed\_network](#input\_allowed\_network) | The types of service endpoints to set on the Secrets Manager instance. Possible values are `private-only` or `public-and-private`. | `string` | `"public-and-private"` | no |
97-
| <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 |
97+
| <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/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
9898
| <a name="input_enable_event_notification"></a> [enable\_event\_notification](#input\_enable\_event\_notification) | Set this to true to enable lifecycle notifications for your Secrets Manager instance by connecting an Event Notifications service. When setting this to true, a value must be passed for `existing_en_instance_crn` and `existing_sm_instance_crn` must be null. | `bool` | `false` | no |
9999
| <a name="input_endpoint_type"></a> [endpoint\_type](#input\_endpoint\_type) | The type of endpoint (public or private) to connect to the Secrets Manager API. The Terraform provider uses this endpoint type to interact with the Secrets Manager API and configure Event Notifications. | `string` | `"public"` | no |
100100
| <a name="input_existing_en_instance_crn"></a> [existing\_en\_instance\_crn](#input\_existing\_en\_instance\_crn) | The CRN of the Event Notifications service to enable lifecycle notifications for your Secrets Manager instance. | `string` | `null` | no |

ibm_catalog.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@
246246
},
247247
{
248248
"key": "skip_event_notification_iam_authorization_policy"
249+
},
250+
{
251+
"key":"cbr_rules"
249252
}
250253
],
251254
"architecture": {

modules/fscloud/README.md

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

4848
| Name | Description | Type | Default | Required |
4949
|------|-------------|------|---------|:--------:|
50-
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (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 |
50+
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (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/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
5151
| <a name="input_enable_event_notification"></a> [enable\_event\_notification](#input\_enable\_event\_notification) | Set this to true to enable lifecycle notifications for your Secrets Manager instance by connecting an Event Notifications service. When setting this to true, a value must be passed for `existing_en_instance_crn` variable. | `bool` | `false` | no |
5252
| <a name="input_existing_en_instance_crn"></a> [existing\_en\_instance\_crn](#input\_existing\_en\_instance\_crn) | The CRN of the Event Notifications service to enable lifecycle notifications for your Secrets Manager instance. | `string` | `null` | no |
5353
| <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 instance in which the key specified in `kms_key_crn` is coming from. | `string` | n/a | yes |

modules/fscloud/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ variable "cbr_rules" {
8484
value = string
8585
}))) }))
8686
enforcement_mode = string
87+
operations = optional(list(object({
88+
api_types = list(object({
89+
api_type_id = string
90+
}))
91+
})))
8792
}))
8893
description = "(list) List of CBR rules to create"
8994
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 Secrets Manager in IBM Cloud projects
2+
3+
Several optional input variables in the IBM Cloud [Secrets Manager 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 = "Secrets Manager 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
@@ -119,6 +119,7 @@ module "secrets_manager" {
119119
existing_en_instance_crn = var.existing_event_notification_instance_crn
120120
skip_en_iam_authorization_policy = var.skip_event_notification_iam_authorization_policy
121121
endpoint_type = local.sm_endpoint_type
122+
cbr_rules = var.cbr_rules
122123
}
123124

124125
# Configure an IBM Secrets Manager IAM credentials engine for an existing IBM Secrets Manager instance.

solutions/standard/variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,27 @@ variable "sm_en_reply_to_email" {
291291
description = "The email address used in the 'reply_to' of any Secret Manager event coming from Event Notifications"
292292
default = "[email protected]"
293293
}
294+
##############################################################
295+
# Context-based restriction (CBR)
296+
##############################################################
297+
298+
variable "cbr_rules" {
299+
type = list(object({
300+
description = string
301+
account_id = string
302+
rule_contexts = list(object({
303+
attributes = optional(list(object({
304+
name = string
305+
value = string
306+
}))) }))
307+
enforcement_mode = string
308+
operations = optional(list(object({
309+
api_types = list(object({
310+
api_type_id = string
311+
}))
312+
})))
313+
}))
314+
description = "(Optional, list) List of CBR rules to create. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/blob/main/solutions/standard/DA-cbr_rules.md)"
315+
default = []
316+
# Validation happens in the rule module
317+
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ variable "cbr_rules" {
8787
value = string
8888
}))) }))
8989
enforcement_mode = string
90+
operations = optional(list(object({
91+
api_types = list(object({
92+
api_type_id = string
93+
}))
94+
})))
9095
}))
9196
description = "(Optional, list) List of CBR rules to create"
9297
default = []

0 commit comments

Comments
 (0)