Skip to content

Commit f2be35d

Browse files
authored
user-access-also
1 parent dc3c4fe commit f2be35d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

terraform-infrastructure/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@ resource "null_resource" "cosmosdb_sql_role_assignment" {
325325
]
326326
}
327327

328+
# Assign the Cosmos DB role to the user running the deployment
329+
resource "null_resource" "cosmosdb_sql_role_assignment_user" {
330+
provisioner "local-exec" {
331+
command = "az cosmosdb sql role assignment create --resource-group ${azurerm_resource_group.rg.name} --account-name ${azurerm_cosmosdb_account.cosmosdb.name} --role-definition-id /subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.rg.name}/providers/Microsoft.DocumentDB/databaseAccounts/${azurerm_cosmosdb_account.cosmosdb.name}/sqlRoleDefinitions/00000000-0000-0000-0000-000000000002 --principal-id ${data.azurerm_client_config.current.object_id} --scope ${azurerm_cosmosdb_account.cosmosdb.id} --role-assignment-id ${local.cosmosdb_role_assignment_id}"
332+
}
333+
334+
depends_on = [
335+
azurerm_cosmosdb_account.cosmosdb
336+
]
337+
}
338+
328339
# Linux Function App
329340
resource "azurerm_linux_function_app" "function_app" {
330341
name = var.function_app_name

0 commit comments

Comments
 (0)