Terraform azurerm_key_vault access_policy overides existing access policies

Viewed 293

I have following code to create azure key vault:

resource "azurerm_key_vault" "key_vault" {
  name                = "example"
  location            = var.location
  resource_group_name = azurerm_resource_group.resource_group.name
  sku_name            = "standard"
  tenant_id           = var.tenant_id
  
  access_policy {
    tenant_id = var.tenant_id
    object_id = azurerm_user_assigned_identity.user_assigned_identity.principal_id
    secret_permissions = [
      "get",
    ]
  }
  
}

Assume following scenario:

  • deploy infrastructure using terraform
  • change key vault access policies manually
  • redeploy using terraform

Terraform will remove access policies that were created manually. Is there a way to tell terraform to not remove existing access policies?

0 Answers
Related