From 5a43792f70a709b58fde126c2a28c3662f73c3fe Mon Sep 17 00:00:00 2001 From: aristosvo <8375124+aristosvo@users.noreply.github.com> Date: Fri, 16 Jul 2021 00:36:36 +0200 Subject: [PATCH] `azurerm_key_vault_access_policy`: Extra nil check to prevent crash (#12576) (#12616) Fixes #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: