Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #6059 - subscription rights for key_vault #6239

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions azurerm/internal/services/keyvault/resource_arm_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,24 @@ func resourceArmKeyVaultCreate(d *schema.ResourceData, meta interface{}) error {
}

// before creating check to see if the key vault exists in the soft delete state
softDeletedKeyVault, err := client.GetDeleted(ctx, name, location)
if err != nil {
if !utils.ResponseWasNotFound(softDeletedKeyVault.Response) {
return fmt.Errorf("Error checking for the presence of an existing Soft-Deleted Key Vault %q (Location %q): %+v", name, location, err)
}
}

// if so, does the user want us to recover it?
recoverSoftDeletedKeyVault := false
if !utils.ResponseWasNotFound(softDeletedKeyVault.Response) {
if !meta.(*clients.Client).Features.KeyVault.RecoverSoftDeletedKeyVaults {
// this exists but the users opted out so they must import this it out-of-band
return fmt.Errorf(optedOutOfRecoveringSoftDeletedKeyVaultErrorFmt(name, location))
if meta.(*clients.Client).Features.KeyVault.RecoverSoftDeletedKeyVaults {
softDeletedKeyVault, err := client.GetDeleted(ctx, name, location)
if err != nil {
if !utils.ResponseWasNotFound(softDeletedKeyVault.Response) {
return fmt.Errorf("Error checking for the presence of an existing Soft-Deleted Key Vault %q (Location %q): %+v", name, location, err)
}
}

recoverSoftDeletedKeyVault = true
// if so, does the user want us to recover it?
if !utils.ResponseWasNotFound(softDeletedKeyVault.Response) {
if !meta.(*clients.Client).Features.KeyVault.RecoverSoftDeletedKeyVaults {
// this exists but the users opted out so they must import this it out-of-band
return fmt.Errorf(optedOutOfRecoveringSoftDeletedKeyVaultErrorFmt(name, location))
}

recoverSoftDeletedKeyVault = true
}
}

tenantUUID := uuid.FromStringOrNil(d.Get("tenant_id").(string))
Expand Down