Search code examples
azureterraformazure-cognitive-servicesinfrastructure-as-code

Azure Cognitive Services - System assigned identity in Terraform


How can you create an Azure Cognitive Services Account with System assigned identity in Terraform?

I have tried the following but got an error: Blocks of type "identity" are not expected here.

resource "azurerm_cognitive_account" "cgsrv" {
  # Conditionally based on feature flag
  count                     = var.to_provision == true ? 1 : 0
  name                      = lower(replace("${var.name_params.prefix}-cgnsrv-${var.name_params.use_case_name}", "-", ""))
  location                  = var.location
  resource_group_name       = var.resourcegroup_name
  kind                      = "CognitiveServices"
  sku_name                  = "S0"

  identity {
    type = "SystemAssigned"
  }
}

Solution

  • You are right, the terraform documentation does not mention this ability at the moment (see here)

    The provider is open-sourced, you can find the source here and it looks like there is a pull request regarding this specific field: https://github.com/terraform-providers/terraform-provider-azurerm/pull/12469