Skip to content

Commit a64d524

Browse files
Copilotjtracey93
andauthored
feat: Decouple container registry zone redundancy from private networking and make flexible (#133)
* Initial plan * Add container_registry_zone_redundancy_enabled variable to decouple ACR zone redundancy from private networking Fixes the issue where zone_redundancy_enabled for the container registry was tied to use_private_networking, causing failures in regions that don't support zone redundancy (e.g., Jio India West). Re-uses the existing agent_container_zone_support / runner_container_zone_support variables to control both container instance zones and container registry zone redundancy. Co-authored-by: jtracey93 <41163455+jtracey93@users.noreply.github.com> * Expose container_registry_zone_redundancy_enabled as separate top-level variable in ADO and GitHub ALZ modules By default, the container registry zone redundancy follows the agent/runner container zone support setting. Users can now independently override it by setting container_registry_zone_redundancy_enabled, enabling scenarios like AZ support for runners but not the registry. Co-authored-by: jtracey93 <41163455+jtracey93@users.noreply.github.com> * Fix zone_redundancy_enabled to use ternary for independent control with private networking When private networking is enabled (Premium SKU), zone_redundancy_enabled is now independently controlled by container_registry_zone_redundancy_enabled. When private networking is disabled (Basic SKU), zone_redundancy_enabled is false as required by the Terraform provider. The ternary pattern is consistent with the other attributes in the resource block. Co-authored-by: jtracey93 <41163455+jtracey93@users.noreply.github.com> * Fix zone redundancy condition for container registry --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jtracey93 <41163455+jtracey93@users.noreply.github.com>
1 parent e8e00a7 commit a64d524

6 files changed

Lines changed: 41 additions & 1 deletion

File tree

alz/azuredevops/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module "azure" {
4949
virtual_network_subnet_address_prefix_container_instances = var.virtual_network_subnet_address_prefix_container_instances
5050
virtual_network_subnet_address_prefix_private_endpoints = var.virtual_network_subnet_address_prefix_private_endpoints
5151
storage_account_replication_type = var.storage_account_replication_type
52+
container_registry_zone_redundancy_enabled = coalesce(var.container_registry_zone_redundancy_enabled, var.agent_container_zone_support)
5253
public_ip_name = local.resource_names.public_ip
5354
nat_gateway_name = local.resource_names.nat_gateway
5455
use_self_hosted_agents = var.use_self_hosted_agents

alz/azuredevops/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,24 @@ variable "agent_container_zone_support" {
394394
**(Optional, default: `true`)** Enable availability zone support for Azure DevOps agent container instances.
395395
396396
When enabled, containers are distributed across availability zones for higher availability and resilience.
397+
Some regions do not support availability zones, in which case this should be set to false.
397398
EOT
398399
type = bool
399400
default = true
400401
}
401402

403+
variable "container_registry_zone_redundancy_enabled" {
404+
description = <<-EOT
405+
**(Optional, default: `null`)** Enable zone redundancy for the Azure Container Registry.
406+
407+
When enabled, the container registry is replicated across availability zones for higher availability.
408+
Some regions do not support zone redundancy, in which case this should be set to false.
409+
Defaults to the value of `agent_container_zone_support` if not set.
410+
EOT
411+
type = bool
412+
default = null
413+
}
414+
402415
variable "built_in_configuration_file_names" {
403416
description = <<-EOT
404417
**(Optional, default: `["config.yaml", "config-hub-and-spoke-vnet.yaml", "config-virtual-wan.yaml"]`)**

alz/github/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module "azure" {
5050
virtual_network_subnet_address_prefix_container_instances = var.virtual_network_subnet_address_prefix_container_instances
5151
virtual_network_subnet_address_prefix_private_endpoints = var.virtual_network_subnet_address_prefix_private_endpoints
5252
storage_account_replication_type = var.storage_account_replication_type
53+
container_registry_zone_redundancy_enabled = coalesce(var.container_registry_zone_redundancy_enabled, var.runner_container_zone_support)
5354
public_ip_name = local.resource_names.public_ip
5455
nat_gateway_name = local.resource_names.nat_gateway
5556
use_self_hosted_agents = var.use_self_hosted_runners

alz/github/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,24 @@ variable "runner_container_zone_support" {
499499
**(Optional, default: `true`)** Enable availability zone support for GitHub runner container instances.
500500
501501
When enabled, containers are distributed across availability zones for higher availability and resilience.
502+
Some regions do not support availability zones, in which case this should be set to false.
502503
EOT
503504
type = bool
504505
default = true
505506
}
506507

508+
variable "container_registry_zone_redundancy_enabled" {
509+
description = <<-EOT
510+
**(Optional, default: `null`)** Enable zone redundancy for the Azure Container Registry.
511+
512+
When enabled, the container registry is replicated across availability zones for higher availability.
513+
Some regions do not support zone redundancy, in which case this should be set to false.
514+
Defaults to the value of `runner_container_zone_support` if not set.
515+
EOT
516+
type = bool
517+
default = null
518+
}
519+
507520
variable "runner_name_environment_variable" {
508521
description = <<-EOT
509522
**(Optional, default: `"GH_RUNNER_NAME"`)** The runner name environment variable supplied to the container.

modules/azure/container_registry.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resource "azurerm_container_registry" "alz" {
55
location = var.azure_location
66
sku = var.use_private_networking ? "Premium" : "Basic"
77
public_network_access_enabled = !var.use_private_networking
8-
zone_redundancy_enabled = var.use_private_networking
8+
zone_redundancy_enabled = var.use_private_networking && var.container_registry_zone_redundancy_enabled
99
network_rule_bypass_option = var.use_private_networking ? "AzureServices" : "None"
1010
}
1111

modules/azure/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,18 @@ variable "container_registry_image_name" {
528528
default = ""
529529
}
530530

531+
variable "container_registry_zone_redundancy_enabled" {
532+
description = <<-EOT
533+
**(Optional, default: `true`)** Enable zone redundancy for the Azure Container Registry.
534+
535+
When enabled, the container registry is replicated across availability zones for higher availability.
536+
Some regions do not support zone redundancy, in which case this should be set to false.
537+
Zone redundancy requires Premium SKU, which is only used when private networking is enabled.
538+
EOT
539+
type = bool
540+
default = true
541+
}
542+
531543
variable "container_registry_image_tag" {
532544
description = <<-EOT
533545
**(Optional, default: `"{{.Run.ID}}"`)** Tag pattern for the container image.

0 commit comments

Comments
 (0)