@@ -24,9 +24,21 @@ locals {
2424 network_security_group_id = lookup (y, " nsg_id" )
2525 direction = contains (keys (y), " source" ) ? " INGRESS" : " EGRESS"
2626 protocol = lookup (y, " protocol" )
27- source = lookup (y, " source" , null )
27+ source = (
28+ alltrue ([
29+ upper (lookup (y, " source_type" , " " )) == local . rule_type_nsg ,
30+ length (regexall (" ocid\\ d+\\ .networksecuritygroup" , lower (lookup (y, " source" , " " )))) == 0 ]) ?
31+ lookup (local. all_nsg_ids , lower (lookup (y, " source" , " " )), null ) :
32+ lookup (y, " source" , null )
33+ )
2834 source_type = lookup (y, " source_type" , null )
29- destination = lookup (y, " destination" , null )
35+ destination = (
36+ alltrue ([
37+ upper (lookup (y, " destination_type" , " " )) == local . rule_type_nsg ,
38+ length (regexall (" ocid\\ d+\\ .networksecuritygroup" , lower (lookup (y, " destination" , " " )))) == 0 ]) ?
39+ lookup (local. all_nsg_ids , lower (lookup (y, " destination" , " " )), null ) :
40+ lookup (y, " destination" , null )
41+ )
3042 destination_type = lookup (y, " destination_type" , null )
3143 }) }
3244
0 commit comments