Skip to content

Commit

Permalink
Merge pull request #2 from schubergphilis/cmk-fix
Browse files Browse the repository at this point in the history
bug: CMK Fix
  • Loading branch information
Dennisvandermeulen authored Jan 7, 2025
2 parents 59ecbf3 + 70bbc9b commit c6c3980
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
locals {
acr_managed_identities = {
system_assigned_user_assigned = (var.acr.managed_identities.system_assigned || length(var.acr.managed_identities.user_assigned_resource_ids) > 0) ? {
this = {
type = var.acr.managed_identities.system_assigned && length(var.acr.managed_identities.user_assigned_resource_ids) > 0 ? "SystemAssigned, UserAssigned" : length(var.acr.managed_identities.user_assigned_resource_ids) > 0 ? "UserAssigned" : "SystemAssigned"
user_assigned_resource_ids = var.acr.managed_identities.user_assigned_resource_ids
}
} : {}
system_assigned = var.acr.managed_identities.system_assigned ? {
this = {
type = "SystemAssigned"
}
} : {}
user_assigned = length(var.acr.managed_identities.user_assigned_resource_ids) > 0 ? {
this = {
type = "UserAssigned"
user_assigned_resource_ids = var.acr.managed_identities.user_assigned_resource_ids
}
} : {}
}
identity_system_assigned_user_assigned = (var.acr.managed_identities.system_assigned && (length(var.acr.managed_identities.user_assigned_resource_ids) > 0 || var.customer_managed_key != null)) ? {
this = {
type = "SystemAssigned, UserAssigned"
user_assigned_resource_ids = setunion(var.acr.managed_identities.user_assigned_resource_ids, try([data.azurerm_user_assigned_identity.this[0].id], []))
}
} : null
identity_system_assigned = var.acr.managed_identities.system_assigned ? {
this = {
type = "SystemAssigned"
user_assigned_resource_ids = null
}
} : null
identity_user_assigned = (length(var.acr.managed_identities.user_assigned_resource_ids) > 0 || var.customer_managed_key != null) ? {
this = {
type = "UserAssigned"
user_assigned_resource_ids = setunion(var.acr.managed_identities.user_assigned_resource_ids, try([data.azurerm_user_assigned_identity.this[0].id], []))
}
} : null

ordered_geo_replications = { for geo in var.acr.georeplications : geo.location => geo }
}
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "azurerm_container_registry" "this" {

content {
identity_client_id = data.azurerm_user_assigned_identity.this[0].client_id
key_vault_key_id = data.azurerm_key_vault_key.this[0].id
key_vault_key_id = data.azurerm_key_vault_key.this[0].versionless_id
}
}

Expand All @@ -41,7 +41,7 @@ resource "azurerm_container_registry" "this" {
}

dynamic "identity" {
for_each = local.acr_managed_identities.system_assigned_user_assigned
for_each = coalesce(local.identity_system_assigned_user_assigned, local.identity_system_assigned, local.identity_user_assigned, {})

content {
type = identity.value.type
Expand Down

0 comments on commit c6c3980

Please sign in to comment.