Skip to content

feat(azure): add optional zone-redundant NAT Gateway and Public IP - #151

Open
Git-PrinceNagar wants to merge 2 commits into
mainfrom
fix/4072-nat-zone-redundancy
Open

Git-PrinceNagar wants to merge 2 commits into
mainfrom
fix/4072-nat-zone-redundancy

Conversation

@Git-PrinceNagar

Copy link
Copy Markdown

Overview/Summary

Adds an opt-in input, nat_gateway_zone_redundancy_enabled (default false), that deploys the bootstrap NAT Gateway and its Public IP as zone-redundant StandardV2 resources.

Refs Azure/Azure-Landing-Zones#4072

The NAT Gateway and Public IP are created as Standard SKU with no zones, so they show as non-compliant against the "Resources should be Zone Resilient" policies. A Standard NAT Gateway can only be zonal or non-zonal; zone redundancy needs a StandardV2 NAT Gateway with a StandardV2 Public IP.

This PR fixes/adds/changes/removes

  1. Adds nat_gateway_zone_redundancy_enabled (bool, default false) to modules/azure, alz/github and alz/azuredevops. alz/local is unchanged: it sets use_self_hosted_agents = false, so it never creates the NAT Gateway.
  2. When true: azurerm_nat_gateway.alz uses sku_name = "StandardV2" with no zones (the provider requires zones to be omitted for StandardV2), and azurerm_public_ip.alz uses sku = "StandardV2" with zones set to the region's zones (local.bootstrap_location_zones, null when the region has none).
  3. Raises the azurerm constraint from ~> 4.20 to ~> 4.67 in modules/azure and the three root modules. 4.67.0 is the first 4.x release that supports StandardV2 on azurerm_nat_gateway and azurerm_public_ip.

Deliberately not changed:

  • The default stays false. Enabling the input replaces the NAT Gateway and Public IP (see below), so turning it on for everyone would do that on every upgrade.
  • No zonal Standard option. A zonal NAT Gateway does not survive a zone outage, and the preview "NAT gateway should be Zone Aligned" policy is the only thing that would favour it.
  • No region check for regions without StandardV2; Azure returns the error at apply, as with the other zone inputs. The variable description says so.

Breaking Changes

  1. The azurerm provider floor is now ~> 4.67. A working folder whose lock file pins an older 4.x needs terraform init -upgrade. Deploy-Accelerator -upgrade starts a new version folder and copies only terraform.tfstate, so terraform init resolves the newest 4.x there.
  2. With the input unset nothing is replaced. Enabling it on an existing bootstrap replaces the NAT Gateway, the Public IP and both associations, because the SKU and zones cannot be changed in place. The runners' outbound IP address changes and outbound connections drop during the apply: use a maintenance window and update any IP allow lists.
  3. StandardV2 NAT Gateway is not available in Canada East, India South Central, Sweden South and West India. Leave the input false there.

Testing Evidence

Unit tests with mocked providers (terraform test in modules/azure; the test file is not part of this PR, the repo has no terraform test suite):

main:       1 passed, 2 failed   PIP sku must be StandardV2 when enabled / NAT gateway sku must be StandardV2 when enabled
this PR:    Success! 3 passed, 0 failed.
reverted networking.tf logic, variable kept:  Failure! 1 passed, 2 failed.

terraform fmt -check -recursive and terraform validate pass for alz/github, alz/azuredevops and alz/local.

Live Azure, centralindia, isolated subscription, everything destroyed afterwards. modules/azure at v7.3.2 was applied with private networking and self-hosted agents, then this branch was applied over that state. An ACI container in the delegated subnet reports its egress IP every 20 seconds.

v7.3.2 baseline this PR, input true
NAT Gateway SKU Standard StandardV2
Public IP SKU / zones Standard / none StandardV2 / ["2","3","1"]
NAT on the ACI-delegated subnet yes yes
ACI egress IP equals the Public IP yes yes
"Public IP addresses should be Zone Resilient" NonCompliant Compliant
"NAT gateway should be Zone Aligned" NonCompliant NonCompliant
  • Input unset on the v7.3.2 state: no resource changes from this PR.
  • Input true: the plan replaced only the NAT Gateway, the Public IP and the two associations (-/+ x4). The re-plan after the apply showed no further changes.
  • "NAT gateway should be Zone Aligned" (preview) is compliant only when the NAT Gateway has exactly one zone. A zone-redundant StandardV2 NAT Gateway has none in its configuration, so it stays flagged. This is a gap in the built-in policy, not something this PR changes.
  • Not tested: a region without availability zones, the regions without StandardV2, and a full Deploy-Accelerator run against GitHub or Azure DevOps. The live run used modules/azure, which both roots call; the roots only pass the input through (terraform validate passes).
  • Plans on the baseline also show network_rule_bypass_for_tasks_enabled = true -> false on the container registry, with and without this PR. That is the azapi_update_resource / azurerm_container_registry conflict fix: use native azurerm attribute for ACR task network bypass #142 fixes.

As part of this Pull Request I have

  • Checked for duplicate Pull Requests
  • Associated it with relevant issues, for tracking and closure.
    • Linked as Refs Azure/Azure-Landing-Zones#4072; the issue is tracked in that repository.
  • Ensured my code/branch is up-to-date with the latest changes in the main branch
  • Performed testing and provided evidence.
  • Updated relevant and associated documentation.
    • The input description is in variables.tf; the accelerator docs page for the bootstrap networking options is not updated in this PR.

#142 also edits the azurerm constraint in modules/azure/terraform.tf; whichever of the two merges second needs a small rebase.

Prince Nagar (BEYONDSOFT CONSULTING INC) added 2 commits November 11, 2026 08:24
…p NAT Gateway

When enabled, the NAT Gateway and its Public IP use the StandardV2 SKU and the Public IP spans the region's availability zones. Default false keeps the Standard SKU with no zones, so existing deployments plan no changes.

Raises the azurerm constraint to ~> 4.67, the first 4.x release with StandardV2 support for azurerm_nat_gateway and azurerm_public_ip.

Refs Azure/Azure-Landing-Zones#4072

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant