Skip to content

Commit b3458bc

Browse files
fix: add capability to add existing rule_contexts in CBR rules in the DA (#678)
1 parent 8e67ba6 commit b3458bc

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ repository:
2424
# and update the description to the current repo description.
2525
description: "This module can be used to provision and configure Context Based Restrictions."
2626

27-
topics: core-team, terraform, ibm-cloud, terraform-module, cbr, context-based-restrictions, graduated, supported
27+
topics: core-team, terraform, ibm-cloud, terraform-module, cbr, context-based-restrictions, graduated, supported, deployable-architecture

solutions/fully-configurable/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ module "cbr_rule" {
6262
for_each = var.cbr_rules
6363
source = "../../modules/cbr-rule-module"
6464
rule_description = each.value.rule_description
65-
# rule_contexts = concat(local.rule_zone_contexts[each.key], each.value.rule_contexts)
66-
rule_contexts = local.rule_zone_contexts[each.key]
65+
rule_contexts = concat(local.rule_zone_contexts[each.key], each.value.rule_contexts)
6766
enforcement_mode = each.value.enforcement_mode
6867
resources = each.value.resources
6968
operations = each.value.operations

solutions/fully-configurable/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
output "network_zone_ids" {
66
value = local.cbr_zone_ids
7-
description = "Array of all the CBR rules created"
7+
description = "List of all the CBR zones created"
88
}
99

1010
output "cbr_rule_ids" {
1111
value = local.cbr_rule_ids
12-
description = "Array of all the CBR zones created"
12+
description = "List of all the CBR rules created"
1313
}

tests/pr_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ func TestFullyConfigurableDAInSchematics(t *testing.T) {
395395
// Sample data for cbr_rules
396396
cbrRules := map[string]interface{}{
397397
"rule1": map[string]interface{}{
398-
"rule_description": "Only allow Redis access from zone1 with ipAddress 192.168.99.99 and zone2 with ipAddress 192.168.98.98",
398+
"rule_description": "Only allow App Configuration access from zone1 with ipAddress 192.168.99.99 and zone2 with ipAddress 192.168.98.98",
399399
"enforcement_mode": "disabled",
400400
"resources": []map[string]interface{}{
401401
{
@@ -406,7 +406,7 @@ func TestFullyConfigurableDAInSchematics(t *testing.T) {
406406
},
407407
{
408408
"name": "serviceName",
409-
"value": "databases-for-redis",
409+
"value": "apprapp",
410410
},
411411
},
412412
},
@@ -415,15 +415,15 @@ func TestFullyConfigurableDAInSchematics(t *testing.T) {
415415
{
416416
"api_types": []map[string]interface{}{
417417
{
418-
"api_type_id": "crn:v1:bluemix:public:context-based-restrictions::::api-type:data-plane",
418+
"api_type_id": "crn:v1:bluemix:public:context-based-restrictions::::api-type:",
419419
},
420420
},
421421
},
422422
},
423423
"zone_keys": []string{"zone1", "zone2"},
424424
},
425425
"rule2": map[string]interface{}{
426-
"rule_description": "Only allow Postgres access from zone2 with ipAddress 192.168.98.98",
426+
"rule_description": "Only allow Container Registry access from zone2 with ipAddress 192.168.98.98",
427427
"resources": []map[string]interface{}{
428428
{
429429
"attributes": []map[string]interface{}{
@@ -433,7 +433,7 @@ func TestFullyConfigurableDAInSchematics(t *testing.T) {
433433
},
434434
{
435435
"name": "serviceName",
436-
"value": "databases-for-postgresql",
436+
"value": "container-registry",
437437
},
438438
},
439439
},
@@ -442,7 +442,7 @@ func TestFullyConfigurableDAInSchematics(t *testing.T) {
442442
{
443443
"api_types": []map[string]interface{}{
444444
{
445-
"api_type_id": "crn:v1:bluemix:public:context-based-restrictions::::api-type:data-plane",
445+
"api_type_id": "crn:v1:bluemix:public:context-based-restrictions::::api-type:",
446446
},
447447
},
448448
},
@@ -487,17 +487,17 @@ func TestRunUpgradeFullyConfigurableDAInSchematics(t *testing.T) {
487487

488488
// Sample data for cbr_zones
489489
cbrZones := map[string]interface{}{
490-
"zone1": map[string]interface{}{
491-
"name": "test-zone-1",
490+
"zone3": map[string]interface{}{
491+
"name": "test-zone-3",
492492
"addresses": []map[string]interface{}{
493493
{
494494
"type": "ipAddress",
495495
"value": "192.168.99.99",
496496
},
497497
},
498498
},
499-
"zone2": map[string]interface{}{
500-
"name": "test-zone-2",
499+
"zone4": map[string]interface{}{
500+
"name": "test-zone-4",
501501
"addresses": []map[string]interface{}{
502502
{
503503
"type": "ipAddress",
@@ -515,7 +515,7 @@ func TestRunUpgradeFullyConfigurableDAInSchematics(t *testing.T) {
515515
// Sample data for cbr_rules
516516
cbrRules := map[string]interface{}{
517517
"rule1": map[string]interface{}{
518-
"rule_description": "Only allow Redis access from zone1 with ipAddress 192.168.99.99 and zone2 with ipAddress 192.168.98.98",
518+
"rule_description": "Only allow Redis access from zone3 with ipAddress 192.168.99.99 and zone4 with ipAddress 192.168.98.98",
519519
"enforcement_mode": "disabled",
520520
"resources": []map[string]interface{}{
521521
{
@@ -540,10 +540,10 @@ func TestRunUpgradeFullyConfigurableDAInSchematics(t *testing.T) {
540540
},
541541
},
542542
},
543-
"zone_keys": []string{"zone1", "zone2"},
543+
"zone_keys": []string{"zone3", "zone4"},
544544
},
545545
"rule2": map[string]interface{}{
546-
"rule_description": "Only allow Postgres access from zone2 with ipAddress 192.168.98.98",
546+
"rule_description": "Only allow Postgres access from zone3 with ipAddress 192.168.98.98",
547547
"resources": []map[string]interface{}{
548548
{
549549
"attributes": []map[string]interface{}{
@@ -567,7 +567,7 @@ func TestRunUpgradeFullyConfigurableDAInSchematics(t *testing.T) {
567567
},
568568
},
569569
},
570-
"zone_keys": []string{"zone2"},
570+
"zone_keys": []string{"zone4"},
571571
},
572572
}
573573

0 commit comments

Comments
 (0)