Terraform keyvault delete protection not work as expected

Viewed 43

When such configuration is used:

    module "key_vault" {
      for_each = var.STAGES
    
      resourceName           = "kv-${each.value}-${local.resource_name_suffix}"
      ...

      purgeProtectionEnabled = true
    }

Then when for some reason secrets should be deleted. Restore gets error:

Error: keyvault.BaseClient#RecoverDeletedSecret: Failure responding to request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=409 Code="Conflict" Message="Secret AzureAiApiKey is currently being deleted." InnerError={"code":"Object
IsBeingDeleted"}

So how to make RecoverDeletedSecret delay or trigger when delete is completed?

1 Answers

According go this github issue, this should already be fixed with version 2.49.

provider "azurerm" {
  version = "~> 2.49.0"
}

Please always try to use the latest azurerm provider. I’ve seen many errors I couldn’t wrap my head around. And more often than not, things are already fixed in later versions of the provider.

Related