Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit d1982cd

Browse files
authored
feat: added support to create SCC CBR rules using new inout cbr_rules (#247)
1 parent 4160c67 commit d1982cd

File tree

4 files changed

+89
-2
lines changed

4 files changed

+89
-2
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Configuring complex inputs for SCC in IBM Cloud projects
2+
3+
Several optional input variables in the IBM Cloud [SCC 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" : "SCC Instance 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+
"enforcement_mode" : "enabled"
54+
"operations" : [{
55+
"api_types" : [{
56+
"api_type_id" : "crn:v1:bluemix:public:context-based-restrictions::::api-type:"
57+
}]
58+
}]
59+
}
60+
]
61+
```

solutions/instances/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This solution supports provisioning and configuring the following infrastructure
3535
| <a name="module_existing_scc_crn_parser"></a> [existing\_scc\_crn\_parser](#module\_existing\_scc\_crn\_parser) | terraform-ibm-modules/common-utilities/ibm//modules/crn-parser | 1.1.0 |
3636
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-ibm-modules/kms-all-inclusive/ibm | 4.19.5 |
3737
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | terraform-ibm-modules/resource-group/ibm | 1.1.6 |
38-
| <a name="module_scc"></a> [scc](#module\_scc) | terraform-ibm-modules/scc/ibm | 1.8.36 |
38+
| <a name="module_scc"></a> [scc](#module\_scc) | terraform-ibm-modules/scc/ibm | 1.9.0 |
3939
| <a name="module_scc_wp"></a> [scc\_wp](#module\_scc\_wp) | terraform-ibm-modules/scc-workload-protection/ibm | 1.4.3 |
4040

4141
### Resources
@@ -57,6 +57,7 @@ This solution supports provisioning and configuring the following infrastructure
5757
|------|-------------|------|---------|:--------:|
5858
| <a name="input_add_bucket_name_suffix"></a> [add\_bucket\_name\_suffix](#input\_add\_bucket\_name\_suffix) | Whether to add a generated 4-character suffix to the created Security and Compliance Center Object Storage bucket name. Applies only if not specifying an existing bucket. Set to `false` not to add the suffix to the bucket name in the `scc_cos_bucket_name` variable. | `bool` | `true` | no |
5959
| <a name="input_attachment_schedule"></a> [attachment\_schedule](#input\_attachment\_schedule) | The scanning schedule. Possible values: `daily`, `every_7_days`, `every_30_days`, `none`. | `string` | `"every_30_days"` | no |
60+
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of context-based restrictions rules to create. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-scc-da/tree/main/solutions/instances/DA-cbr_rules.md) | <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 |
6061
| <a name="input_cos_instance_access_tags"></a> [cos\_instance\_access\_tags](#input\_cos\_instance\_access\_tags) | A list of access tags to apply to the Object Storage instance. Applies only if not specifying an existing instance. | `list(string)` | `[]` | no |
6162
| <a name="input_cos_instance_name"></a> [cos\_instance\_name](#input\_cos\_instance\_name) | The name for the Object Storage instance. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format. | `string` | `"base-security-services-cos"` | no |
6263
| <a name="input_cos_instance_tags"></a> [cos\_instance\_tags](#input\_cos\_instance\_tags) | The list of tags to add to the Object Storage instance. Applies only if not specifying an existing instance. | `list(string)` | `[]` | no |

solutions/instances/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ moved {
237237
module "scc" {
238238
source = "terraform-ibm-modules/scc/ibm"
239239
existing_scc_instance_crn = var.existing_scc_instance_crn
240-
version = "1.8.36"
240+
version = "1.9.0"
241241
resource_group_id = module.resource_group.resource_group_id
242242
region = local.scc_instance_region
243243
instance_name = local.scc_instance_name
@@ -252,6 +252,7 @@ module "scc" {
252252
attach_wp_to_scc_instance = var.provision_scc_workload_protection && var.existing_scc_instance_crn == null
253253
wp_instance_crn = var.provision_scc_workload_protection && var.existing_scc_instance_crn == null ? module.scc_wp[0].crn : null
254254
skip_scc_wp_auth_policy = var.skip_scc_workload_protection_auth_policy
255+
cbr_rules = var.cbr_rules
255256
}
256257

257258
#######################################################################################################################

solutions/instances/variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,27 @@ variable "scc_en_email_list" {
351351
description = "The list of email addresses to notify when Security and Compliance Center triggers an event."
352352
default = []
353353
}
354+
355+
##############################################################
356+
# Context-based restriction (CBR)
357+
##############################################################
358+
359+
variable "cbr_rules" {
360+
type = list(object({
361+
description = string
362+
account_id = string
363+
rule_contexts = list(object({
364+
attributes = optional(list(object({
365+
name = string
366+
value = string
367+
}))) }))
368+
enforcement_mode = string
369+
operations = optional(list(object({
370+
api_types = list(object({
371+
api_type_id = string
372+
}))
373+
})))
374+
}))
375+
description = "(Optional, list) List of context-based restrictions rules to create. [Learn more](https://github.com/terraform-ibm-modules/terraform-ibm-scc-da/tree/main/solutions/instances/DA-cbr_rules.md)"
376+
default = []
377+
}

0 commit comments

Comments
 (0)