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_certificate: Support curve property for EC keys #10867

Merged
merged 6 commits into from
Apr 29, 2021
Merged

azurerm_key_vault_certificate: Support curve property for EC keys #10867

merged 6 commits into from
Apr 29, 2021

Conversation

simonbrady
Copy link
Contributor

@simonbrady simonbrady commented Mar 7, 2021

The azurerm_key_vault_certificate resource allows for ECDSA certificates with a key type of EC, but unlike azurerm_key_vault_key it doesn't let the user specify which elliptic curve to use.

The v7.1 Create Certificate API adds a crv attribute to the KeyProperties type, so this PR updates the keyvault service to the v7.1 API and adds curve to the allowed key properties, matching the behaviour of azurerm_key_vault_key wherever possible.

All the keyvault acceptance tests pass (including new coverage for curve), but I'm raising this as a draft PR to get feedback on some implications of the change.

@simonbrady simonbrady changed the title azurem_keyvault_certificate: Support curve property for EC keys azurerm_keyvault_certificate: Support curve property for EC keys Mar 7, 2021
@simonbrady simonbrady changed the title azurerm_keyvault_certificate: Support curve property for EC keys azurerm_key_vault_certificate: Support curve property for EC keys Mar 7, 2021
@simonbrady
Copy link
Contributor Author

Minor merge conflicts with #10873 which updates the keyvault/mgmt API, but I can easily rebase this if that one's merged first.

@simonbrady
Copy link
Contributor Author

Rebased off master, questions in #10868 still to be resolved.

Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Hi @simonbrady, thanks for this PR! Overall this looks good and the tests are passing, but where possible we need to ensure that existing configurations are not broken. I have some suggestions inline.

If you want to compute the key_size property, you should be able to do this if you move the logic in your gist into the expandKeyVaultCertificatePolicy() function - just be sure to prefer the value set in configuration to prevent unwanted diffs. Also add the Computed flag to the key_size property to let Terraform know.

@@ -102,9 +102,9 @@ func resourceKeyVaultKey() *schema.Resource {
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(keyvault.P256),
string(keyvault.P256K),
string(keyvault.P384),
string(keyvault.P521),
Copy link
Member

Choose a reason for hiding this comment

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

Can we add the old value as a hardcoded string, and translate it in the expandKeyVaultCertificatePolicy() function so that existing configurations continue to work?

You will probably need to use CustomizeDiff to suppress the new value in the event the old value is used.

We can add a TODO to remove it in v3.0.

Suggested change
string(keyvault.P521),
string(keyvault.P521),
"SECP256K1", // TODO: remove this in v3.0 as it was renamed to keyvault.P256K

string(keyvault.ECHSM),
string(keyvault.RSA),
string(keyvault.RSAHSM),
}, false),
Copy link
Member

Choose a reason for hiding this comment

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

We should be case-insensitive here until v3.0 to avoid breaking existing configs

Suggested change
}, false),
}, true), // TODO: make this case-sensitive in v3.0

@manicminer manicminer assigned simonbrady and unassigned manicminer Apr 26, 2021
@katbyte katbyte added this to the v2.57.0 milestone Apr 26, 2021
@manicminer manicminer marked this pull request as ready for review April 29, 2021 16:06
@manicminer
Copy link
Member

@simonbrady I hope you don't mind, I've pushed the changes detailed in my earlier review including making the key_size property optional in azurerm_key_vault_certificate. Let me know if this doesn't capture your original intent, I'm going to open this for further review in the meantime. Thanks!

@manicminer manicminer requested a review from a team April 29, 2021 16:29
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ghost ghost added size/XL and removed size/XXL labels Apr 29, 2021
@manicminer
Copy link
Member

Rebased, now re-running tests

@manicminer
Copy link
Member

Tests passing (service flapping, passed on second run)

Screenshot 2021-04-29 at 21 48 15
Screenshot 2021-04-29 at 21 48 28

@manicminer manicminer linked an issue Apr 29, 2021 that may be closed by this pull request
@manicminer manicminer merged commit b860001 into hashicorp:master Apr 29, 2021
manicminer added a commit that referenced this pull request Apr 29, 2021
@simonbrady
Copy link
Contributor Author

Thanks for all the assistance @manicminer - I hadn't had time to get to this, but I'm going to claim that's exactly what I would've done :)

@ghost ghost removed the waiting-response label Apr 29, 2021
@ghost
Copy link

ghost commented Apr 30, 2021

This has been released in version 2.57.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.57.0"
}
# ... other configuration ...

@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 May 30, 2021
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.

azurerm_key_vault_certificate: Support curve property for EC keys
3 participants