bcgov / Cloud-Pathfinder-Azure

Apache License 2.0
0 stars 0 forks source link

Azure Firewall Configuration / Modification #113

Closed AErmie closed 2 months ago

AErmie commented 2 months ago

Currently, Azure Firewall is deployed and implemented using the Azure landing zones Terraform module.

We need to research and test what is and is not supported through the CAF Terraform module, in particular the Azure Firewall Policy. This should be tested by creating a Rule Collection, along with a sample DNAT Rule, Network Rule, and Application Rule.

Additionally, Firewall Policy Analytics should be enabled and configured to use an existing Log Analytics Workspace. Other Firewall configurations (ie. custom DNS, Threat Intelligence, TLS Inspection, IDPS, Web Categories, etc.) will be handled on-demand/as needed at a later point.

[!NOTE] From initial investigation and research, although the Azure Terraform CAF Enterprise Scale module creates a base Azure Firewall Policy, it does not support the lower-level resources, such as Policy Rule Collections, Rules, etc.

There is an Azure Verified Module for the Azure Firewall Policy that we could look into using. It's just not clear if it can use an existing policy, or we're required to create a new one.

The challenge if we use an AVM module to update an existing Policy, means there will be a battle for ownership between the CAF and AVM whenever we run the various pipelines.

Include confirming what traffic is routed through the firewall.

Acceptance Criteria

AErmie commented 2 months ago

Part of these modifications will require updating the vWAN configuration, to include routing intents and routing policies, to force Internet traffic to/through the Firewall.

AErmie commented 2 months ago

Successfully applied changes to the vWAN routing intent and routing policy, to force Internet traffic through the Azure Firewall.

AErmie commented 2 months ago

Sample code has bee created (and tested) that successfully...

Sample code can be found in the /azure_firewall/ directory in thie azure-lz-core-forge repo.

[!NOTE] This code is not based on the Azure Verified Module, but is custom created.

image.png
AErmie commented 2 months ago

Was able to update the existing Azure Policy and enable the Firewall Policy Analytics, using the azapi_update_resource resource.

However, when re-running the Forge Plan workflow, it shows that it will remove/undo the policy analytics configurations.

This means that we need to figure out how to enable/control the Policy Analytics through the CAF deployment. In the CAF connectivity locals.tf file, there is a reference to azurerm_firewall_policy but it is unclear how to properly configure this. It's position in the code implies it is part of the azure_firewall block, but when testing this, it did not work. Additionally, there is an open GitHub Issue (Feature Request: Enable Policy Analytics on Firewall Policy), which provides a work-around (using the advanced custom_settings).

AErmie commented 2 months ago

Successfully updated the CAF settings.connectivity.tf file, using and advanced block, to enable Azure Firewall Policy Analytics through the CAF module.

IMPORTANT

Note the following important points discovered: