Skip to content

Commit

Permalink
Remove key vault policy from state iff it existed
Browse files Browse the repository at this point in the history
This fixes the test added in the previous commit, while retaining the ability to
reflect access policy deletion by deleting the key vault itself.
  • Loading branch information
jen20 committed Feb 21, 2019
1 parent 0cfd63c commit e99279b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion azurerm/resource_arm_key_vault_access_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ func resourceArmKeyVaultAccessPolicyCreateOrDelete(d *schema.ResourceData, meta

keyVault, err := client.Get(ctx, resourceGroup, vaultName)
if err != nil {
if utils.ResponseWasNotFound(keyVault.Response) {
// If the key vault does not exist but this is not a new resource, the policy
// which previously existed was deleted with the key vault, so reflect that in
// state. If this is a new resource and key vault does not exist, it's likely
// a bad ID was given.
if utils.ResponseWasNotFound(keyVault.Response) && !d.IsNewResource() {
log.Printf("[DEBUG] Parent Key Vault %q was not found in Resource Group %q - removing from state!", vaultName, resourceGroup)
d.SetId("")
return nil
Expand Down

0 comments on commit e99279b

Please sign in to comment.