Skip to content

Commit

Permalink
fix: user-assigned identities not being assigned (#38)
Browse files Browse the repository at this point in the history
Fixes #37
  • Loading branch information
hknutsen authored Sep 27, 2023
1 parent 5b91a6f commit 81466d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ locals {
is_windows = var.kind == "Windows"
function_app = local.is_windows ? azurerm_windows_function_app.this[0] : azurerm_linux_function_app.this[0]

# Auto assign Key Vault reference identity
identity_ids = concat(compact([var.key_vault_reference_identity_id]), var.identity_ids)

# If system_assigned_identity_enabled is true, value is "SystemAssigned".
# If identity_ids is non-empty, value is "UserAssigned".
# If system_assigned_identity_enabled is true and identity_ids is non-empty, value is "SystemAssigned, UserAssigned".
identity_type = join(", ", compact([var.system_assigned_identity_enabled ? "SystemAssigned" : "", length(var.identity_ids) > 0 ? "UserAssigned" : ""]))
identity_ids = compact([var.key_vault_reference_identity_id])
identity_type = join(", ", compact([var.system_assigned_identity_enabled ? "SystemAssigned" : "", length(local.identity_ids) > 0 ? "UserAssigned" : ""]))
}

resource "azurerm_linux_function_app" "this" {
Expand Down Expand Up @@ -58,7 +60,7 @@ resource "azurerm_linux_function_app" "this" {

content {
type = local.identity_type
identity_ids = concat(local.identity_ids, var.identity_ids)
identity_ids = local.identity_ids
}
}

Expand Down Expand Up @@ -125,7 +127,7 @@ resource "azurerm_windows_function_app" "this" {

content {
type = local.identity_type
identity_ids = concat(local.identity_ids, var.identity_ids)
identity_ids = local.identity_ids
}
}

Expand Down

0 comments on commit 81466d8

Please sign in to comment.