Skip to content

Commit 3b6937b

Browse files
fix: fix issue where only first network zone is attached to CBR rule (#93)
1 parent 278f04f commit 3b6937b

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ Brewfile.lock.json
5454

5555
# Visual Studio Code
5656
.vscode/
57+
58+
# ignore go workspace only used for local developlment
59+
go.work

cbr-rule-module/main.tf

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,52 @@ resource "ibm_cbr_rule" "cbr_rule" {
1010

1111
dynamic "contexts" {
1212
for_each = var.rule_contexts
13+
iterator = context
1314
content {
1415
dynamic "attributes" {
15-
for_each = var.rule_contexts[0].attributes == null ? [] : var.rule_contexts[0].attributes
16+
for_each = context.value["attributes"] == null ? [] : context.value["attributes"]
1617
iterator = attribute
1718
content {
18-
name = attribute.value.name
19-
value = attribute.value.value
19+
name = attribute.value["name"]
20+
value = attribute.value["value"]
2021
}
2122
}
2223
}
2324
}
2425

2526
dynamic "resources" {
2627
for_each = var.resources
28+
iterator = resource
2729
content {
2830
dynamic "attributes" {
29-
for_each = var.resources[0].attributes == null ? [] : var.resources[0].attributes
31+
for_each = resource.value["attributes"] == null ? [] : resource.value["attributes"]
3032
iterator = attribute
3133
content {
32-
name = attribute.value.name
33-
value = attribute.value.value
34-
operator = attribute.value.operator
34+
name = attribute.value["name"]
35+
value = attribute.value["value"]
36+
operator = attribute.value["operator"]
3537
}
3638
}
3739
dynamic "tags" {
38-
for_each = var.resources[0].tags == null ? [] : var.resources[0].tags
40+
for_each = resource.value["tags"] == null ? [] : resource.value["tags"]
3941
iterator = tag
4042
content {
41-
name = tag.value.name
42-
value = tag.value.value
43+
name = tag.value["name"]
44+
value = tag.value["value"]
4345
}
4446
}
4547
}
4648
}
4749

4850
dynamic "operations" {
4951
for_each = var.operations
52+
iterator = operation
5053
content {
5154
dynamic "api_types" {
52-
for_each = var.operations[0].api_types == null ? null : var.operations[0].api_types
53-
iterator = apitype
55+
for_each = operation.value["api_types"]
56+
iterator = api_type
5457
content {
55-
api_type_id = apitype.value["api_type_id"]
58+
api_type_id = api_type.value["api_type_id"]
5659
}
5760
}
5861
}

0 commit comments

Comments
 (0)