diff --git a/modules/compute/container_group/managed_identities.tf b/modules/compute/container_group/managed_identities.tf index f7be6f24d9..91db5fe397 100644 --- a/modules/compute/container_group/managed_identities.tf +++ b/modules/compute/container_group/managed_identities.tf @@ -3,19 +3,24 @@ # locals { + // Adjusted to handle direct identity ID if provided + managed_direct_identity = try(var.settings.identity.id != null ? [var.settings.identity.id] : [], []) + managed_local_identities = flatten([ for managed_identity_key in try(var.settings.identity.managed_identity_keys, []) : [ - var.combined_resources.managed_identities[var.client_config.landingzone_key][managed_identity_key].id + try(var.combined_resources.managed_identities[var.client_config.landingzone_key][managed_identity_key].id, null) ] ]) managed_remote_identities = flatten([ for lz_key, value in try(var.settings.identity.remote, []) : [ - for managed_identity_key in value.managed_identity_keys : [ - var.combined_resources.managed_identities[lz_key][managed_identity_key].id + for managed_identity_key in try(value.managed_identity_keys, []) : [ + try(var.combined_resources.managed_identities[lz_key][managed_identity_key].id, null) ] ] ]) - managed_identities = concat(local.managed_local_identities, local.managed_remote_identities) + // Include the direct identity ID in the final list + managed_identities = concat(local.managed_direct_identity, local.managed_local_identities, local.managed_remote_identities) } +