kind-afternoon-60990
03/19/2025, 12:37 PMrcg = network.FirewallPolicyRuleCollectionGroup(
imported_rcg_result.name,
resource_group_name=resource_group_name,
firewall_policy_name=firewall_policy.name,
priority=priority,
rule_collections=merged_rule_collections,
opts=ResourceOptions(provider=virtual_wan_provider, id=existing_rcg.id)
)
this rcg is imported programatically in case it is not existing and that seams to work preview(shows the read)/up runs through. goal is that the rule collections are getting updated with new ones but somehow no change is detected while at the moment there is no rule collection present and merged_rule_collections have content:
Merged rule collections: [{'name': 'network-rule-collection-smallnet-dev-002', 'priority': 1000, 'action': 'Allow', 'rules': [{'name': 'network-rule-smallnet-dev-002-0', 'direction': 'Inbound', 'protocol': '*', 'sourceAddresses': ['10.238.8.0/27'], 'destinationAddresses': ['10.0.0.0/8'], 'destinationPorts': ['*'], 'sourcePorts': []}]}, {'name': 'application-rule-collection-smallnet-dev-002', 'priority': 26000, 'action': 'Allow', 'rules': [{'name': 'application-rule-smallnet-dev-002-0', 'priority': 26000, 'direction': 'Inbound', 'protocol': '*', 'sourceAddresses': ['10.238.8.0/27'], 'destinationAddresses': [], 'destinationPorts': [], 'sourcePorts': [], 'fqdns': []}, {'name': 'application-rule-smallnet-dev-002-1', 'priority': 26001, 'direction': 'Inbound', 'protocol': '*', 'sourceAddresses': ['10.238.8.0/27'], 'destinationAddresses': [], 'destinationPorts': [], 'sourcePorts': [], 'fqdns': []}, {'name': 'application-rule-smallnet-dev-002-2', 'priority': 26002, 'direction': 'Inbound', 'protocol': '*', 'sourceAddresses': ['10.238.8.0/27'], 'destinationAddresses': [], 'destinationPorts': [], 'sourcePorts': [], 'fqdns': []}]}, {'name': 'nat-rule-collection-smallnet-dev-002', 'priority': 55000, 'action': 'Dnat', 'rules': []}]
that are dummy rules but should be actually working. aynone an idea?faint-pager-13674
03/26/2025, 9:12 AMpulumi up --refresh
?kind-afternoon-60990
03/26/2025, 9:16 AMfaint-pager-13674
03/26/2025, 9:32 AMkind-afternoon-60990
03/26/2025, 9:33 AMfaint-pager-13674
03/26/2025, 9:35 AMkind-afternoon-60990
03/26/2025, 9:36 AMkind-afternoon-60990
03/26/2025, 9:37 AMkind-afternoon-60990
03/26/2025, 9:38 AMkind-afternoon-60990
03/26/2025, 9:38 AMkind-afternoon-60990
03/26/2025, 9:38 AMkind-afternoon-60990
03/26/2025, 9:39 AMtry:
existing_rcg = network.FirewallPolicyRuleCollectionGroup.get(
selected_rcg.name,
id=selected_rcg.id,
# resource_group_name=resource_group_name,
# firewall_policy_name=firewall_policy.name,
# rule_collection_group_name=selected_rcg.name,
opts=pulumi.ResourceOptions(provider=virtual_wan_provider)
)
existing_rcg.name.apply(lambda name: <http://pulumi.log.info|pulumi.log.info>(f"Successfully retrieved existing Rule Collection Group: {name}"))
except Exception as e:
pulumi.log.error(f"Error getting collection group: {e}")
kind-afternoon-60990
03/26/2025, 9:39 AMtry:
updated_rcg = network.FirewallPolicyRuleCollectionGroup(
"imported_rcg",
name=selected_rcg.name,
resource_group_name=resource_group_name,
firewall_policy_name=firewall_policy.name,
priority=selected_rcg.priority,
rule_collections=merged_rule_collections,
opts=ResourceOptions(provider=virtual_wan_provider, id=selected_rcg.id),
)
updated_rcg.id.apply(lambda id: <http://pulumi.log.info|pulumi.log.info>(f"Updated rule collection group: {id}"))
except Exception as e:
pulumi.log.error(f"Rule Collection Group not updated for LZ {lz_full_id}. error: {str(e)}")
raise
kind-afternoon-60990
03/26/2025, 9:39 AMfaint-pager-13674
03/26/2025, 9:42 AMnetwork.FirewallPolicyRuleCollectionGroup
- You cannot update an existing resource if it is managed by a different project. I would recommend to fall back on Azure CLI where you can safely get the existing rules then update the rules and finally update it. The problem with this approach is that if TF runs again which might remove the rule you just added.kind-afternoon-60990
03/26/2025, 9:43 AMkind-afternoon-60990
03/26/2025, 9:44 AMfaint-pager-13674
03/26/2025, 9:45 AMkind-afternoon-60990
03/26/2025, 9:45 AMkind-afternoon-60990
03/26/2025, 9:46 AMfaint-pager-13674
03/26/2025, 9:46 AMkind-afternoon-60990
03/26/2025, 9:47 AMfaint-pager-13674
03/26/2025, 9:47 AMfaint-pager-13674
03/26/2025, 9:47 AMkind-afternoon-60990
03/26/2025, 9:48 AMfaint-pager-13674
03/26/2025, 9:49 AMfaint-pager-13674
03/26/2025, 9:50 AMkind-afternoon-60990
03/26/2025, 9:56 AMkind-afternoon-60990
03/26/2025, 12:26 PMrcg = network.FirewallPolicyRuleCollectionGroup(
"fwpolrcg-" + lz_full_id,
name="fwpolrcg-" + lz_full_id,
resource_group_name=resource_group_name,
firewall_policy_name=firewall_policy.name,
priority=101,
rule_collections=[{
"action": {
"type": network.FirewallPolicyFilterRuleCollectionActionType.DENY,
},
"name": "Example-Filter-Rule-Collection",
"priority": 100,
"rule_collection_type": "FirewallPolicyFilterRuleCollection",
"rules": [{
"destination_addresses": ["*"],
"destination_ports": ["*"],
"ip_protocols": [network.FirewallPolicyRuleNetworkProtocol.TCP],
"name": "network-rule1",
"rule_type": "NetworkRule",
"source_addresses": ["10.1.25.0/24"],
}],
}],
opts=ResourceOptions(provider=virtual_wan_provider),
)
and it seems there is a general issue:
~ azure-native:network:FirewallPolicyRuleCollectionGroup fwpolrcg-smallnet-dev-002 updating (0s) [diff: ~ruleCollections]
@ updating....
~ azure-native:network:FirewallPolicyRuleCollectionGroup fwpolrcg-smallnet-dev-002 updating (0s) [diff: ~ruleCollections]; error: Status=400 Message="{
~ azure-native:network:FirewallPolicyRuleCollectionGroup fwpolrcg-smallnet-dev-002 **updating failed** [diff: ~ruleCollections]; error: Status=400 Message="{
pulumi:pulumi:Stack hub-networking-smallnet-dev-002 running error: update failed
pulumi:pulumi:Stack hub-networking-smallnet-dev-002 **failed** 1 error; 6 messages
Diagnostics:
pulumi:pulumi:Stack (hub-networking-smallnet-dev-002):
Creating Network Rule Dict: NetworkRule(name='allow-internal-traffic', description='Allow traffic to internal network', ip_protocols=['TCP', 'UDP', 'ICMP'], destination_ports=['*'], source_addresses=['10.238.8.0/27'], destination_addresses=['10.0.0.0/8'], source_ip_groups=[], destination_ip_groups=[], rule_type='Network')
Created Network Rule Dict: {'name': 'allow-internal-traffic', 'description': 'Allow traffic to internal network', 'ipProtocols': ['TCP', 'UDP', 'ICMP'], 'destinationPorts': ['*'], 'sourceAddresses': ['10.238.8.0/27'], 'destinationAddresses': ['10.0.0.0/8'], 'sourceIpGroups': [], 'destinationIpGroups': [], 'ruleType': 'Network'}
Merged rule collections: [{'name': 'network-rule-collection-smallnet-dev-002', 'priority': 1000, 'action': {'type': 'Allow'}, 'ruleCollectionType': 'FirewallPolicyNetworkRuleCollection', 'rules': [{'name': 'allow-internal-traffic', 'description': 'Allow traffic to internal network', 'ipProtocols': ['TCP', 'UDP', 'ICMP'], 'destinationPorts': ['*'], 'sourceAddresses': ['10.238.8.0/27'], 'destinationAddresses': ['10.0.0.0/8'], 'sourceIpGroups': [], 'destinationIpGroups': [], 'ruleType': 'Network'}]}, {'name': 'application-rule-collection-smallnet-dev-002', 'priority': 26000, 'action': {'type': 'Allow'}, 'ruleCollectionType': 'FirewallPolicyApplicationRuleCollection', 'rules': []}, {'name': 'nat-rule-collection-smallnet-dev-002', 'priority': 55000, 'action': {'type': 'Dnat'}, 'ruleCollectionType': 'FirewallPolicyNatRuleCollection', 'rules': []}]
Using priority 1000 for network rule collection
Using priority 26000 for application rule collection
Using priority 55000 for NAT rule collection
error: update failed
azure-native:network:FirewallPolicyRuleCollectionGroup (fwpolrcg-smallnet-dev-002):
error: Status=400 Message="{
"Message": "The request is invalid.",
"ModelState": {
"resource.properties.ruleCollections[0]": [
"An error has occurred."
]
}
}"
I've tried also a nat rule. nothing worksfaint-pager-13674
03/26/2025, 12:28 PMkind-afternoon-60990
03/26/2025, 12:28 PMkind-afternoon-60990
03/26/2025, 12:29 PMkind-afternoon-60990
03/26/2025, 12:30 PMfaint-pager-13674
03/26/2025, 2:40 PMfaint-pager-13674
03/26/2025, 2:41 PMkind-afternoon-60990
04/04/2025, 1:46 PM