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

❔What is the proper way to avoid KeyVault name collision when purge protection is enabled? #128

Open
RobBiddle opened this issue Jul 4, 2024 · 0 comments

Comments

@RobBiddle
Copy link

When creating KeyVault Resources named via this module I've run into an issue where a mistake was made (by me) requiring deletion of the resource. We're using Purge Protection on KeyVaults so when one is deleted in Azure I can't create another KeyVault using the same name, at least not for 90 days, which would slow down development quite a bit.

Here's what I'm doing:

  1. KeyVault is created using name = join("-", [module.naming.key_vault.slug, lower(each.key), module.naming.random])
  2. Notice something is b0rk3d so I need to tear everything down.
  3. Delete the KeyVault from Azure.
  4. Delete it from the Terraform State File.
  5. Run terraform apply
    The result is Terraform attempts to create a KeyVault using same name (same "random" ending characters in name), which throws an error stating the KeyVault already exists.

I've been working around it by restoring the KeyVault and importing the Resource into Terraform state.
I'd much rather the replacement KeyVault Resource be created by Terraform with a new unique name instead.
What is the proper way to make this happen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant