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 block added #19113

Merged
merged 12 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion internal/services/keyvault/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package client

import (
"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2021-10-01/keyvault" // nolint: staticcheck
keyvaultmgmt "github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
keyvaultmgmt "github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

type Client struct {
Expand Down
8 changes: 4 additions & 4 deletions internal/services/keyvault/encrypted_value_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

var _ sdk.DataSource = EncryptedValueDataSource{}
Expand All @@ -37,9 +37,9 @@ func (EncryptedValueDataSource) Arguments() map[string]*schema.Schema {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
string(keyvault.RSA15),
string(keyvault.RSAOAEP),
string(keyvault.RSAOAEP256),
string(keyvault.JSONWebKeyEncryptionAlgorithmRSA15),
string(keyvault.JSONWebKeyEncryptionAlgorithmRSAOAEP),
string(keyvault.JSONWebKeyEncryptionAlgorithmRSAOAEP256),
}, false),
},
"encrypted_data": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ resource "azurerm_key_vault" "test" {
"Purge",
"Recover",
"Update",
"GetRotationPolicy",
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

type KeyVaultCertificateContactsResource struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

func dataSourceKeyVaultCertificate() *pluginsdk.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
Expand All @@ -14,6 +13,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

func resourceKeyVaultCertificateIssuer() *pluginsdk.Resource {
Expand Down
54 changes: 27 additions & 27 deletions internal/services/keyvault/key_vault_certificate_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/Azure/go-autorest/autorest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand All @@ -24,6 +23,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

func resourceKeyVaultCertificate() *pluginsdk.Resource {
Expand Down Expand Up @@ -125,10 +125,10 @@ func resourceKeyVaultCertificate() *pluginsdk.Resource {
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(keyvault.P256),
string(keyvault.P256K),
string(keyvault.P384),
string(keyvault.P521),
string(keyvault.JSONWebKeyCurveNameP256),
string(keyvault.JSONWebKeyCurveNameP256K),
string(keyvault.JSONWebKeyCurveNameP384),
string(keyvault.JSONWebKeyCurveNameP521),
}, false),
},
"exportable": {
Expand All @@ -155,11 +155,11 @@ func resourceKeyVaultCertificate() *pluginsdk.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(keyvault.EC),
string(keyvault.ECHSM),
string(keyvault.RSA),
string(keyvault.RSAHSM),
string(keyvault.Oct),
string(keyvault.JSONWebKeyTypeEC),
string(keyvault.JSONWebKeyTypeECHSM),
string(keyvault.JSONWebKeyTypeRSA),
string(keyvault.JSONWebKeyTypeRSAHSM),
string(keyvault.JSONWebKeyTypeOct),
}, false),
},
"reuse_key": {
Expand All @@ -186,8 +186,8 @@ func resourceKeyVaultCertificate() *pluginsdk.Resource {
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(keyvault.AutoRenew),
string(keyvault.EmailContacts),
string(keyvault.CertificatePolicyActionAutoRenew),
string(keyvault.CertificatePolicyActionEmailContacts),
}, false),
},
},
Expand Down Expand Up @@ -255,15 +255,15 @@ func resourceKeyVaultCertificate() *pluginsdk.Resource {
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: validation.StringInSlice([]string{
string(keyvault.CRLSign),
string(keyvault.DataEncipherment),
string(keyvault.DecipherOnly),
string(keyvault.DigitalSignature),
string(keyvault.EncipherOnly),
string(keyvault.KeyAgreement),
string(keyvault.KeyCertSign),
string(keyvault.KeyEncipherment),
string(keyvault.NonRepudiation),
string(keyvault.KeyUsageTypeCRLSign),
string(keyvault.KeyUsageTypeDataEncipherment),
string(keyvault.KeyUsageTypeDecipherOnly),
string(keyvault.KeyUsageTypeDigitalSignature),
string(keyvault.KeyUsageTypeEncipherOnly),
string(keyvault.KeyUsageTypeKeyAgreement),
string(keyvault.KeyUsageTypeKeyCertSign),
string(keyvault.KeyUsageTypeKeyEncipherment),
string(keyvault.KeyUsageTypeNonRepudiation),
}, false),
},
},
Expand Down Expand Up @@ -819,22 +819,22 @@ func expandKeyVaultCertificatePolicy(d *pluginsdk.ResourceData) (*keyvault.Certi
keyType := props["key_type"].(string)
keySize := props["key_size"].(int)

if keyType == string(keyvault.EC) || keyType == string(keyvault.ECHSM) {
if keyType == string(keyvault.JSONWebKeyTypeEC) || keyType == string(keyvault.JSONWebKeyTypeECHSM) {
if curve == "" {
return nil, fmt.Errorf("`curve` is required when creating an EC key")
}
// determine key_size if not specified
if keySize == 0 {
switch curve {
case string(keyvault.P256), string(keyvault.P256K):
case string(keyvault.JSONWebKeyCurveNameP256), string(keyvault.JSONWebKeyCurveNameP256K):
keySize = 256
case string(keyvault.P384):
case string(keyvault.JSONWebKeyCurveNameP384):
keySize = 384
case string(keyvault.P521):
case string(keyvault.JSONWebKeyCurveNameP521):
keySize = 521
}
}
} else if keyType == string(keyvault.RSA) || keyType == string(keyvault.RSAHSM) {
} else if keyType == string(keyvault.JSONWebKeyTypeRSA) || keyType == string(keyvault.JSONWebKeyTypeRSAHSM) {
if keySize == 0 {
return nil, fmt.Errorf("`key_size` is required when creating an RSA key")
}
Expand All @@ -858,7 +858,7 @@ func expandKeyVaultCertificatePolicy(d *pluginsdk.ResourceData) (*keyvault.Certi
as := v.([]interface{})
a := as[0].(map[string]interface{})
lifetimeAction.Action = &keyvault.Action{
ActionType: keyvault.ActionType(a["action_type"].(string)),
ActionType: keyvault.CertificatePolicyAction(a["action_type"].(string)),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

func dataSourceKeyVaultCertificates() *pluginsdk.Resource {
Expand Down
12 changes: 6 additions & 6 deletions internal/services/keyvault/key_vault_key_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"math/big"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/keyvault/7.4/keyvault"
)

func dataSourceKeyVaultKey() *pluginsdk.Resource {
Expand Down Expand Up @@ -170,7 +170,7 @@ func dataSourceKeyVaultKeyRead(d *pluginsdk.ResourceData, meta interface{}) erro
d.Set("curve", key.Crv)

if key := resp.Key; key != nil {
if key.Kty == keyvault.RSA || key.Kty == keyvault.RSAHSM {
if key.Kty == keyvault.JSONWebKeyTypeRSA || key.Kty == keyvault.JSONWebKeyTypeRSAHSM {
nBytes, err := base64.RawURLEncoding.DecodeString(*key.N)
if err != nil {
return fmt.Errorf("failed to decode N: %+v", err)
Expand All @@ -187,7 +187,7 @@ func dataSourceKeyVaultKeyRead(d *pluginsdk.ResourceData, meta interface{}) erro
if err != nil {
return fmt.Errorf("failed to read public key: %+v", err)
}
} else if key.Kty == keyvault.EC || key.Kty == keyvault.ECHSM {
} else if key.Kty == keyvault.JSONWebKeyTypeEC || key.Kty == keyvault.JSONWebKeyTypeECHSM {
// do ec keys
xBytes, err := base64.RawURLEncoding.DecodeString(*key.X)
if err != nil {
Expand All @@ -202,11 +202,11 @@ func dataSourceKeyVaultKeyRead(d *pluginsdk.ResourceData, meta interface{}) erro
Y: big.NewInt(0).SetBytes(yBytes),
}
switch key.Crv {
case keyvault.P256:
case keyvault.JSONWebKeyCurveNameP256:
publicKey.Curve = elliptic.P256()
case keyvault.P384:
case keyvault.JSONWebKeyCurveNameP384:
publicKey.Curve = elliptic.P384()
case keyvault.P521:
case keyvault.JSONWebKeyCurveNameP521:
publicKey.Curve = elliptic.P521()
}
if publicKey.Curve != nil {
Expand Down
Loading