Skip to content

Commit 512a33b

Browse files
Aashiq-JAk-sky
andauthored
feat: create global 'deny' rule when more narrow scoped rules are created by the module (#396) <br> * minimum required provider version is 1.62.0. <br> * Ability to scope a rule per region. <br> * Support for multiple attributes per rule for a service. <br> * Remove public default context set to 1.1.1.1 <br> * 0 context rule for services by default, which will deny all requests made to a service. (Note: By default enforcement mode is set to report-only). <br> * option create a global 'deny' rule for all the scoped rule for a service. By default it is set to true.
* feat: ability to scope a rule per region * global deny rule code * set global-deny to false for kms * add support for multiple attribute --------- Co-authored-by: Akash Kumar <akash.kumar@ibm.com>
1 parent 0c171fb commit 512a33b

File tree

20 files changed

+106
-73
lines changed

20 files changed

+106
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ You need the following permissions to run this module.
103103
| Name | Version |
104104
|------|---------|
105105
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
106-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.56.1, < 2.0.0 |
106+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.62.0, < 2.0.0 |
107107

108108
### Modules
109109

examples/fscloud/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ module "cbr_account_level" {
7777
"description" = "kms-rule-example-of-customized-description"
7878
"enforcement_mode" = "enabled"
7979
"instance_id" = module.key_protect_module.key_protect_guid
80+
"global_deny" = false
81+
"target_rg" = module.resource_group.resource_group_id
8082
}
8183
"cloud-object-storage" = {
8284
"enforcement_mode" = "enabled"
83-
"instance_id" = module.key_protect_module.key_protect_guid
85+
"target_rg" = module.resource_group.resource_group_id
86+
"global_deny" = false
8487
}
8588
}
8689

examples/fscloud/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.56.1"
7+
version = "1.62.0"
88
}
99
}
1010
}

examples/multi-resource-rule/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.56.1"
7+
version = "1.62.0"
88
}
99
}
1010
}

examples/multi-service-profile/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.56.1"
7+
version = "1.62.0"
88
}
99
}
1010
}

examples/multizone-rule/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.56.1"
7+
version = "1.62.0"
88
}
99
}
1010
}

examples/zone/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
55
ibm = {
66
source = "IBM-Cloud/ibm"
7-
version = "1.56.1"
7+
version = "1.62.0"
88
}
99
}
1010
}

modules/cbr-rule-module/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module "ibm_cbr" "rule" {
5555
| Name | Version |
5656
|------|---------|
5757
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
58-
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.56.1, < 2.0.0 |
58+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.62.0, < 2.0.0 |
5959

6060
### Modules
6161

@@ -74,7 +74,7 @@ No modules.
7474
| <a name="input_enforcement_mode"></a> [enforcement\_mode](#input\_enforcement\_mode) | (String) The rule enforcement mode | `string` | `"report"` | no |
7575
| <a name="input_operations"></a> [operations](#input\_operations) | (Optional, List) The operations this rule applies to, by default it will protect all of the service and platform APIs the target service supports. | <pre>list(object({<br> api_types = list(object({<br> api_type_id = string<br> }))<br> }))</pre> | <pre>[<br> {<br> "api_types": [<br> {<br> "api_type_id": "crn:v1:bluemix:public:context-based-restrictions::::api-type:"<br> }<br> ]<br> }<br>]</pre> | no |
7676
| <a name="input_resources"></a> [resources](#input\_resources) | (List) The resources this rule apply to | <pre>list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> operator = optional(string)<br> })))<br> tags = optional(list(object({<br> name = string<br> value = string<br> operator = optional(string)<br> })))<br> }))</pre> | n/a | yes |
77-
| <a name="input_rule_contexts"></a> [rule\_contexts](#input\_rule\_contexts) | (List) The contexts the rule applies to | <pre>list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> })))<br> }))</pre> | n/a | yes |
77+
| <a name="input_rule_contexts"></a> [rule\_contexts](#input\_rule\_contexts) | (List) The contexts the rule applies to | <pre>list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> })))<br> }))</pre> | `[]` | no |
7878
| <a name="input_rule_description"></a> [rule\_description](#input\_rule\_description) | (Optional, String) The description of the rule | `string` | `null` | no |
7979

8080
### Outputs

modules/cbr-rule-module/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "ibm_cbr_rule" "cbr_rule" {
99
enforcement_mode = var.enforcement_mode
1010

1111
dynamic "contexts" {
12-
for_each = var.rule_contexts
12+
for_each = length(var.rule_contexts) > 0 ? var.rule_contexts : []
1313
iterator = context
1414
content {
1515
dynamic "attributes" {

modules/cbr-rule-module/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ variable "rule_contexts" {
2929
}))
3030
description = "(List) The contexts the rule applies to"
3131
validation {
32-
condition = anytrue(
32+
condition = length(var.rule_contexts) == 0 || alltrue(
3333
flatten(
3434
[for rule_context in var.rule_contexts :
3535
[for attribute in rule_context.attributes : alltrue([
@@ -42,6 +42,7 @@ variable "rule_contexts" {
4242
)
4343
error_message = "Value should be a valid rule context name"
4444
}
45+
default = []
4546
}
4647

4748
variable "enforcement_mode" {

0 commit comments

Comments
 (0)