Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: agent container zone support #59

Merged
merged 6 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/end-to-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ jobs:
"westeurope",
"westus2",
"westus3",
"australiaeast"
"australiaeast",
"swedencentral"
)

$locationsSingleAvailabilityZone = @(
Expand Down Expand Up @@ -215,6 +216,9 @@ jobs:
$Inputs["use_separate_repository_for_templates"] = "true"
$Inputs["use_self_hosted_runners"] = $enableSelfHostedAgents
$Inputs["use_runner_group"] = "true"
if($location -eq "swedencentral") {
$Inputs["runner_container_zone_support"] = "false"
}
}

if($versionControlSystem -eq "azuredevops") {
Expand All @@ -226,6 +230,9 @@ jobs:
$Inputs["azure_devops_create_project"] = "true"
$Inputs["azure_devops_project_name"] = "alz-test-$uniqueId"
$Inputs["use_self_hosted_agents"] = $enableSelfHostedAgents
if($location -eq "swedencentral") {
$Inputs["agent_container_zone_support"] = "false"
}
}

if($versionControlSystem -eq "local") {
Expand All @@ -238,6 +245,7 @@ jobs:
$Inputs["subscription_id_connectivity"] = "${{ vars.ARM_SUBSCRIPTION_ID }}"
$Inputs["subscription_id_identity"] = "${{ vars.ARM_SUBSCRIPTION_ID }}"
$Inputs["subscription_id_management"] = "${{ vars.ARM_SUBSCRIPTION_ID }}"

$Inputs["parent_management_group_display_name"] = "Tenant Root Group"
$Inputs["child_management_group_display_name"] = "E2E Test"
$Inputs["resource_group_location"] = $location
Expand Down
4 changes: 2 additions & 2 deletions alz/azuredevops/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ locals {
memory = var.agent_container_memory
cpu_max = var.agent_container_cpu_max
memory_max = var.agent_container_memory_max
zones = ["1"]
zones = var.agent_container_zone_support ? ["1"] : []
}
agent_02 = {
container_instance_name = local.resource_names.container_instance_02
Expand All @@ -70,7 +70,7 @@ locals {
memory = var.agent_container_memory
cpu_max = var.agent_container_cpu_max
memory_max = var.agent_container_memory_max
zones = ["2"]
zones = var.agent_container_zone_support ? ["2"] : []
}
} : {}
}
Expand Down
2 changes: 1 addition & 1 deletion alz/azuredevops/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
}
azapi = {
source = "azure/azapi"
version = "~> 1.13"
version = "~> 2.0"
}
azuredevops = {
source = "microsoft/azuredevops"
Expand Down
6 changes: 6 additions & 0 deletions alz/azuredevops/variables.hidden.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ variable "agent_container_memory_max" {
default = 4
}

variable "agent_container_zone_support" {
description = "The container zone support"
type = bool
default = true
}

variable "built_in_configurartion_file_names" {
description = "Built-in configuration file name"
type = list(string)
Expand Down
4 changes: 2 additions & 2 deletions alz/github/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ locals {
memory = var.runner_container_memory
cpu_max = var.runner_container_cpu_max
memory_max = var.runner_container_memory_max
zones = ["1"]
zones = var.runner_container_zone_support ? ["1"] : []
}
agent_02 = {
container_instance_name = local.resource_names.container_instance_02
Expand All @@ -78,7 +78,7 @@ locals {
memory = var.runner_container_memory
cpu_max = var.runner_container_cpu_max
memory_max = var.runner_container_memory_max
zones = ["2"]
zones = var.runner_container_zone_support ? ["2"] : []
}
} : {}
}
Expand Down
2 changes: 1 addition & 1 deletion alz/github/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
}
azapi = {
source = "azure/azapi"
version = "~> 1.13"
version = "~> 2.0"
}
github = {
source = "integrations/github"
Expand Down
6 changes: 6 additions & 0 deletions alz/github/variables.hidden.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ variable "runner_container_memory_max" {
default = 4
}

variable "runner_container_zone_support" {
description = "The container zone support"
type = bool
default = true
}

variable "runner_name_environment_variable" {
description = "The runner name environment variable supplied to the container"
type = string
Expand Down
2 changes: 1 addition & 1 deletion alz/local/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
}
azapi = {
source = "azure/azapi"
version = "~> 1.13"
version = "~> 2.0"
}
local = {
source = "hashicorp/local"
Expand Down
2 changes: 1 addition & 1 deletion modules/azure/container_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource "azurerm_container_group" "alz" {
ip_address_type = var.use_private_networking ? "Private" : "None"
os_type = "Linux"
subnet_ids = var.use_private_networking ? [azurerm_subnet.container_instances[0].id] : []
zones = each.value.zones
zones = length(local.bootstrap_location_zones) == 0 ? null : each.value.zones

identity {
type = "UserAssigned"
Expand Down
17 changes: 17 additions & 0 deletions modules/azure/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ data "http" "ip" {
min_delay_ms = 500
}
}

module "regions" {
source = "Azure/avm-utl-regions/azurerm"
version = "0.3.0"
use_cached_data = false
availability_zones_filter = false
recommended_filter = false
}

locals {
regions = { for region in module.regions.regions_by_name : region.name => {
display_name = region.display_name
zones = region.zones == null ? [] : region.zones
}
}
bootstrap_location_zones = local.regions[var.azure_location].zones
}
2 changes: 1 addition & 1 deletion modules/azure/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
azapi = {
source = "azure/azapi"
version = "~> 1.13"
version = "~> 2.0"
}
http = {
source = "hashicorp/http"
Expand Down
Loading