Skip to content

Commit

Permalink
feat: add support to reference module nsgs in the nsg rules
Browse files Browse the repository at this point in the history
  • Loading branch information
robo-cap committed Nov 18, 2024
1 parent dc41e91 commit b708484
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions modules/network/rules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,21 @@ locals {
network_security_group_id = lookup(y, "nsg_id")
direction = contains(keys(y), "source") ? "INGRESS" : "EGRESS"
protocol = lookup(y, "protocol")
source = lookup(y, "source", null)
source = (
alltrue([
upper(lookup(y, "source_type", "")) == local.rule_type_nsg,
length(regexall("ocid\\d+\\.networksecuritygroup", lower(lookup(y, "source", "")))) == 0]) ?
lookup(local.all_nsg_ids, lower(lookup(y, "source", "")), null) :
lookup(y, "source", null)
)
source_type = lookup(y, "source_type", null)
destination = lookup(y, "destination", null)
destination = (
alltrue([
upper(lookup(y, "destination_type", "")) == local.rule_type_nsg,
length(regexall("ocid\\d+\\.networksecuritygroup", lower(lookup(y, "destination", "")))) == 0]) ?
lookup(local.all_nsg_ids, lower(lookup(y, "destination", "")), null) :
lookup(y, "destination", null)
)
destination_type = lookup(y, "destination_type", null)
}) }

Expand Down

0 comments on commit b708484

Please sign in to comment.