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

azurerm_key_vault_key_rotation_policy - New resource #18603

Closed

Conversation

aristosvo
Copy link
Contributor

@aristosvo aristosvo commented Oct 1, 2022

Depends on #18576

Fixes #14471
Implemented in #19113 as inline properties.

  • AccTests
  • Docs

@aristosvo aristosvo force-pushed the keyvault/key_rotation_policy branch from 113a1fa to f076782 Compare October 15, 2022 18:43
Copy link
Collaborator

@magodo magodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR!
I've taken a look through and left some comments inline, but this is mostly looking good to me 👍

website/docs/r/key_vault_key_rotation_policy.html.markdown Outdated Show resolved Hide resolved
website/docs/r/key_vault_key_rotation_policy.html.markdown Outdated Show resolved Hide resolved
website/docs/r/key_vault_key_rotation_policy.html.markdown Outdated Show resolved Hide resolved
website/docs/r/key_vault_key_rotation_policy.html.markdown Outdated Show resolved Hide resolved
website/docs/r/key_vault_key_rotation_policy.html.markdown Outdated Show resolved Hide resolved
Key Rotation Policys can be imported using the `resource id`, e.g.

```shell
terraform import azurerm_key_vault_key_rotation_policy.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.KeyVault/vaults/vault1/keys/key1/rotationpolicy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If each key can only has a single rotation, then we can simply reuse the same format of key resource id as the rotation policy id:

Suggested change
terraform import azurerm_key_vault_key_rotation_policy.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.KeyVault/vaults/vault1/keys/key1/rotationpolicy
terraform import azurerm_key_vault_key_rotation_policy.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.KeyVault/vaults/vault1/keys/key1

This makes the id format align with others (even amount of segments), meanwhile it saves your effort to manually implement the ID parser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make it indeed easier.., but as it has its own ID and is implemented in this PR as a separate resource, I'd argue that it makes sense to have its specific ID (and resource ID).

@aristosvo
Copy link
Contributor Author

Thanks for this PR!

I've taken a look through and left some comments inline, but this is mostly looking good to me 👍

Hi @magodo ! Thanks for the review.

One thing that is still on my mind: should we not implement this in-line of the azurerm_key_vault_key instead? Just picking your brain here:

  • it is impossible to really delete this resource
  • it is tightly coupled to one key
  • only one per key
  • checks on key dates make some extra validations possible

This is one of the things I've been deciding beforehand based on gutfeeling, I'm not aware if there are guidelines to help us here :)

@magodo
Copy link
Collaborator

magodo commented Nov 1, 2022

@aristosvo That makes sense to me! While I'd prefer listening to other's opinion. @katbyte WDYT?

@katbyte
Copy link
Collaborator

katbyte commented Nov 2, 2022

@aristosvo,

you make some really good arguments and i think i agree with you. generally a 1:1 relation alone is reason enough to consider add it to the existing resource. but when you add in that it cannot be deleted and it really is just "enabling feature X on resource Y" it does make a lot of sense to be part of the key-vault resource.

i always like to think of the UX when making these sort of choices and what I as a user would expect/want, and is there any real benefit to making it separate rather than just trying to mirror the apis as terraform is a stateful DSL not a set of CRUD api operations.

unfortunately we do not have any real guidelines here yet that we all agree on, and something like this would be great to pr into the contributor docs so we can actually nail down some firm guidelines on when/when not to and discuss on the PR what we all think they should be.

improving those docs is something i'll be looking towards later this year so adding this topic to the list 😃

@aristosvo
Copy link
Contributor Author

aristosvo commented Nov 2, 2022

Based on previous comment I'll close this PR for now and try to implement it inline first. These experiences may show it was not a good idea, if that's the case then this one is reopened easily enough.

Edit: new PR -> #19113

@aristosvo
Copy link
Contributor Author

Reopened and updated to have a good comparison

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Azure Keyvault key rotation and rotation policy
3 participants