Skip to content

Commit d63ee7c

Browse files
fix: acr task mi network permissions (#102)
1 parent 7da4093 commit d63ee7c

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

modules/azure/container_registry.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ resource "azurerm_container_registry" "alz" {
99
network_rule_bypass_option = var.use_private_networking ? "AzureServices" : "None"
1010
}
1111

12+
resource "azapi_update_resource" "network_rule_bypass_allowed_for_tasks" {
13+
count = var.use_self_hosted_agents && var.use_private_networking ? 1 : 0
14+
type = "Microsoft.ContainerRegistry/registries@2025-05-01-preview"
15+
resource_id = azurerm_container_registry.alz[0].id
16+
body = {
17+
properties = {
18+
networkRuleBypassAllowedForTasks = true
19+
}
20+
}
21+
}
22+
1223
resource "azurerm_container_registry_task" "alz" {
1324
count = var.use_self_hosted_agents ? 1 : 0
1425
name = "image-build-task"
@@ -39,7 +50,10 @@ resource "azurerm_container_registry_task_schedule_run_now" "alz" {
3950
lifecycle {
4051
replace_triggered_by = [azurerm_container_registry_task.alz]
4152
}
42-
depends_on = [azurerm_role_assignment.container_registry_push_for_task]
53+
depends_on = [
54+
azurerm_role_assignment.container_registry_push_for_task,
55+
azapi_update_resource.network_rule_bypass_allowed_for_tasks
56+
]
4357
}
4458

4559
resource "azurerm_role_assignment" "container_registry_pull_for_container_instance" {

0 commit comments

Comments
 (0)