Skip to content

Commit 65b202f

Browse files
committed
Workaround with powershell for container app identity
1 parent f1f4a6b commit 65b202f

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

terraform/.terraform.lock.hcl

Lines changed: 33 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/get_identity.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
param (
2+
[string]$resourceGroup,
3+
[string]$appName
4+
)
5+
6+
$principalId = az containerapp show `
7+
--name $appName `
8+
--resource-group $resourceGroup `
9+
--query "identity.principalId" `
10+
-o tsv
11+
12+
@{ principal_id = $principalId } | ConvertTo-Json -Compres

terraform/main.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,19 @@ resource "azurerm_container_app" "ca_app" {
110110
}
111111
}
112112

113+
data "external" "container_app_identity" {
114+
program = ["powershell", "${path.module}/get_identity.ps1", data.azurerm_resource_group.rg.name, azurerm_container_app.ca_app.name]
115+
116+
depends_on = [azurerm_container_app.ca_app]
117+
}
118+
113119
resource "azurerm_key_vault_access_policy" "ca_app_kv_policy" {
114120
key_vault_id = azurerm_key_vault.kv.id
115121
tenant_id = var.tenant_id
116-
object_id = azurerm_container_app.ca_app.identity[0].principal_id
122+
object_id = data.external.container_app_identity.result["principal_id"]
117123

118124
secret_permissions = [
119125
"List",
120126
"Get"
121127
]
122-
123-
depends_on = [azurerm_container_app.ca_app]
124128
}

0 commit comments

Comments
 (0)