fix 101-cosmos-db-aad-rbac example (#144)

This commit is contained in:
Dingjia Chen
2023-02-14 00:01:24 -06:00
committed by GitHub
parent 911b419f25
commit 5557a85e0b
3 changed files with 33 additions and 5 deletions

View File

@ -1,7 +1,11 @@
data "azurerm_client_config" "current" {}
locals {
current_user_object_id = coalesce(var.msi_id, data.azurerm_client_config.current.object_id)
}
resource "azurerm_resource_group" "example" {
name = var.resource_group_name
name = "${random_pet.prefix.id}-rg"
location = var.location
}
@ -81,6 +85,10 @@ resource "azurerm_cosmosdb_sql_role_assignment" "example" {
resource_group_name = azurerm_resource_group.example.name
account_name = azurerm_cosmosdb_account.example.name
role_definition_id = azurerm_cosmosdb_sql_role_definition.example.id
principal_id = data.azurerm_client_config.current.object_id
principal_id = local.current_user_object_id
scope = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.example.name}/providers/Microsoft.DocumentDB/databaseAccounts/${azurerm_cosmosdb_account.example.name}"
}
resource "random_pet" "prefix" {
prefix = var.name_prefix
}