Skip to content

Commit

Permalink
Fix rule id and names
Browse files Browse the repository at this point in the history
  • Loading branch information
juliocc committed Aug 8, 2023
1 parent b21cd41 commit 3c4febe
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions modules/net-vpc-firewall-policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
locals {
_rules_egress = {
for name, rule in merge(var.egress_rules) :
"egress/${name}" => merge(rule, { direction = "EGRESS" })
"egress/${name}" => merge(rule, { name = name, direction = "EGRESS" })
}
_rules_ingress = {
for name, rule in merge(var.ingress_rules) :
"ingress/${name}" => merge(rule, { direction = "INGRESS" })
"ingress/${name}" => merge(rule, { name = name, direction = "INGRESS" })
}
rules = merge(
local.factory_egress_rules, local.factory_ingress_rules,
Expand Down
2 changes: 1 addition & 1 deletion modules/net-vpc-firewall-policy/net-global.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ resource "google_compute_network_firewall_policy_rule" "net-global" {
)
project = var.parent_id
firewall_policy = google_compute_network_firewall_policy.net-global.0.name
rule_name = each.key
rule_name = local.rules[each.key].name
action = local.rules[each.key].action
description = local.rules[each.key].description
direction = local.rules[each.key].direction
Expand Down
2 changes: 1 addition & 1 deletion modules/net-vpc-firewall-policy/net-regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "google_compute_region_network_firewall_policy_rule" "net-regional" {
project = var.parent_id
region = var.region
firewall_policy = google_compute_region_network_firewall_policy.net-regional.0.name
rule_name = each.key
rule_name = local.rules[each.key].name
action = local.rules[each.key].action
description = local.rules[each.key].description
direction = local.rules[each.key].direction
Expand Down
8 changes: 3 additions & 5 deletions tests/modules/net_vpc_firewall_policy/examples/factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

values:
module.firewall-policy.google_compute_firewall_policy.hierarchical[0]:
parent: folders/1234567890
short_name: test-1
module.firewall-policy.google_compute_firewall_policy_association.hierarchical["test"]:
attachment_target: folders/4567890123
name: test-1-test
module.firewall-policy.google_compute_firewall_policy_rule.hierarchical["icmp"]:
module.firewall-policy.google_compute_firewall_policy_rule.hierarchical["egress/icmp"]:
action: allow
direction: INGRESS
disabled: false
Expand All @@ -42,7 +41,7 @@ values:
priority: 1000
target_resources: null
target_service_accounts: null
module.firewall-policy.google_compute_firewall_policy_rule.hierarchical["smtp"]:
module.firewall-policy.google_compute_firewall_policy_rule.hierarchical["ingress/smtp"]:
action: deny
direction: EGRESS
disabled: false
Expand All @@ -68,7 +67,7 @@ values:
priority: 900
target_resources: null
target_service_accounts: null
module.firewall-policy.google_compute_firewall_policy_rule.hierarchical["ssh"]:
module.firewall-policy.google_compute_firewall_policy_rule.hierarchical["ingress/ssh"]:
action: allow
direction: INGRESS
disabled: false
Expand Down Expand Up @@ -97,4 +96,3 @@ counts:
google_compute_firewall_policy: 1
google_compute_firewall_policy_association: 1
google_compute_firewall_policy_rule: 3

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ values:
src_threat_intelligences: null
priority: 900
project: my-project
rule_name: egress/smtp
rule_name: smtp
target_secure_tags: []
target_service_accounts: null
module.firewall-policy.google_compute_network_firewall_policy_rule.net-global["ingress/icmp"]:
Expand All @@ -72,7 +72,7 @@ values:
src_threat_intelligences: null
priority: 1000
project: my-project
rule_name: ingress/icmp
rule_name: icmp
target_secure_tags: []
target_service_accounts: null
module.firewall-policy.google_compute_network_firewall_policy_rule.net-global["ingress/mgmt"]:
Expand All @@ -99,7 +99,7 @@ values:
src_threat_intelligences: null
priority: 1001
project: my-project
rule_name: ingress/mgmt
rule_name: mgmt
target_secure_tags: []
target_service_accounts: null
module.firewall-policy.google_compute_network_firewall_policy_rule.net-global["ingress/ssh"]:
Expand Down Expand Up @@ -127,7 +127,7 @@ values:
src_threat_intelligences: null
priority: 1002
project: my-project
rule_name: ingress/ssh
rule_name: ssh
target_secure_tags: []
target_service_accounts: null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ values:
name: test-1
project: my-project
region: europe-west8
module.firewall-policy.google_compute_region_network_firewall_policy_association.net-regional["my-vpc"]:
firewall_policy: test-1
name: test-1-my-vpc
project: my-project
Expand Down Expand Up @@ -47,7 +48,7 @@ values:
priority: 900
project: my-project
region: europe-west8
rule_name: egress/smtp
rule_name: smtp
target_secure_tags: []
target_service_accounts: null
module.firewall-policy.google_compute_region_network_firewall_policy_rule.net-regional["ingress/icmp"]:
Expand Down Expand Up @@ -75,11 +76,10 @@ values:
priority: 1000
project: my-project
region: europe-west8
rule_name: ingress/icmp
rule_name: icmp
target_secure_tags: []
target_service_accounts: null


counts:
google_compute_region_network_firewall_policy: 1
google_compute_region_network_firewall_policy_association: 1
Expand Down

0 comments on commit 3c4febe

Please sign in to comment.