From 62933aa356657959eb7bd5da87f0d23bce2669bb Mon Sep 17 00:00:00 2001 From: Aris van Ommeren Date: Thu, 15 Jul 2021 23:55:54 +0200 Subject: [PATCH] Extra nil check to prevent crash key_vault_access_policy (#12576) --- .../services/keyvault/key_vault_access_policy_resource.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azurerm/internal/services/keyvault/key_vault_access_policy_resource.go b/azurerm/internal/services/keyvault/key_vault_access_policy_resource.go index 27ee9b5b1bb2..bddca448b4d7 100644 --- a/azurerm/internal/services/keyvault/key_vault_access_policy_resource.go +++ b/azurerm/internal/services/keyvault/key_vault_access_policy_resource.go @@ -177,7 +177,11 @@ func resourceKeyVaultAccessPolicyCreateOrDelete(d *pluginsdk.ResourceData, meta if resp.Properties == nil || resp.Properties.AccessPolicies == nil { return fmt.Errorf("failed reading Access Policies for %q (resource group %q)", vaultName, id.ResourceGroup) } + accessPolicyRaw := FindKeyVaultAccessPolicy(resp.Properties.AccessPolicies, objectId, applicationIdRaw) + if accessPolicyRaw == nil { + return fmt.Errorf("failed finding this specific Access Policy on Azure KeyVault %q (resource group %q)", vaultName, id.ResourceGroup) + } accessPolicy = *accessPolicyRaw default: