Skip to content

Commit

Permalink
rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxu92 committed Mar 13, 2024
1 parent 081f292 commit 4e88fee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ import (

type AutomaticModel struct {
DurationAfterCreation string `tfschema:"duration_after_creation"`
TimeBeforeExpiry string `tfschema:"time_before_expiry"`
DurationBeforeExpiry string `tfschema:"duration_before_expiry"`
}
type RotationPolicyModel struct {
Automatic []AutomaticModel `tfschema:"automatic"`
ExpireAfter string `tfschema:"expire_after"`
Automatic []AutomaticModel `tfschema:"automatic"`
ExpireAfterDuration string `tfschema:"expire_after_duration"`
// NotifyBeforeExpiry string `tfschema:"notify_before_expiry"`
}
type KeyVaultManagedHardwareSecurityModuleKeyModel struct {
Expand Down Expand Up @@ -215,16 +215,16 @@ func (KeyVaultManagedHardwareSecurityModuleKeyResouece) Arguments() map[string]*
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"expire_after": {
"expire_after_duration": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validate.ISO8601DurationBetween("P28D", "P100Y"),
AtLeastOneOf: []string{
"rotation_policy.0.expire_after",
"rotation_policy.0.expire_after_duration",
"rotation_policy.0.automatic",
},
RequiredWith: []string{
"rotation_policy.0.expire_after",
"rotation_policy.0.expire_after_duration",
},
},

Expand All @@ -240,16 +240,16 @@ func (KeyVaultManagedHardwareSecurityModuleKeyResouece) Arguments() map[string]*
ValidateFunc: validate.ISO8601Duration,
AtLeastOneOf: []string{
"rotation_policy.0.automatic.0.duration_after_creation",
"rotation_policy.0.automatic.0.time_before_expiry",
"rotation_policy.0.automatic.0.duration_before_expiry",
},
},
"time_before_expiry": {
"duration_before_expiry": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validate.ISO8601Duration,
AtLeastOneOf: []string{
"rotation_policy.0.automatic.0.duration_after_creation",
"rotation_policy.0.automatic.0.time_before_expiry",
"rotation_policy.0.automatic.0.duration_before_expiry",
},
},
},
Expand Down Expand Up @@ -748,8 +748,8 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) expandKeyVaultKeyRotat
policy := v[0]

var expiryTime *string = nil // needs to be set to nil if not set
if policy.ExpireAfter != "" {
expiryTime = pointer.To(policy.ExpireAfter)
if policy.ExpireAfterDuration != "" {
expiryTime = pointer.To(policy.ExpireAfterDuration)
}

lifetimeActions := make([]keyvault.LifetimeActions, 0)
Expand All @@ -767,8 +767,8 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) expandKeyVaultKeyRotat
lifetimeActionRotate.Trigger.TimeAfterCreate = &autoRotationRaw.DurationAfterCreation
}

if autoRotationRaw.TimeBeforeExpiry != "" {
lifetimeActionRotate.Trigger.TimeBeforeExpiry = &autoRotationRaw.TimeBeforeExpiry
if autoRotationRaw.DurationBeforeExpiry != "" {
lifetimeActionRotate.Trigger.TimeBeforeExpiry = &autoRotationRaw.DurationBeforeExpiry
}

lifetimeActions = append(lifetimeActions, lifetimeActionRotate)
Expand All @@ -789,7 +789,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) flattenKeyVaultKeyRota

var policy RotationPolicyModel
if input.Attributes != nil {
policy.ExpireAfter = pointer.From(input.Attributes.ExpiryTime)
policy.ExpireAfterDuration = pointer.From(input.Attributes.ExpiryTime)
}

if input.LifetimeActions != nil {
Expand All @@ -801,7 +801,7 @@ func (k KeyVaultManagedHardwareSecurityModuleKeyResouece) flattenKeyVaultKeyRota
if strings.EqualFold(string(action.Type), string(keyvault.ActionTypeRotate)) {
var autoRotation AutomaticModel
autoRotation.DurationAfterCreation = pointer.From(trigger.TimeAfterCreate)
autoRotation.TimeBeforeExpiry = pointer.From(trigger.TimeBeforeExpiry)
autoRotation.DurationBeforeExpiry = pointer.From(trigger.TimeBeforeExpiry)
policy.Automatic = append(policy.Automatic, autoRotation)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ resource "azurerm_key_vault_managed_hardware_security_module_key" "test" {
rotation_policy {
automatic {
time_before_expiry = "P30D"
duration_before_expiry = "P30D"
}
expire_after = "P60D"
expire_after_duration = "P60D"
}
tags = {
Env = "test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ resource "azurerm_key_vault_managed_hardware_security_module_key" "example" {
"verify",
]
rotation_policy {
expire_after = "P66D"
expire_after_duration = "P66D"
automatic {
time_before_expiry = "P30D"
duration_before_expiry = "P30D"
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ The following arguments are supported:

A `rotation_policy` block supports the following:

* `expire_after` - (Optional) Expire a Managed Hardware Security Module Key after given duration as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).
* `expire_after_duration` - (Optional) Expire a Managed Hardware Security Module Key after given duration as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).

* `automatic` - (Optional) An `automatic` block as defined below.

Expand All @@ -215,7 +215,7 @@ An `automatic` block supports the following:

* `duration_after_creation` - (Optional) Rotate automatically at a duration after create as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).

* `time_before_expiry` - (Optional) Rotate automatically at a duration before expiry as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).
* `duration_before_expiry` - (Optional) Rotate automatically at a duration before expiry as an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations).

## Attributes Reference

Expand Down

0 comments on commit 4e88fee

Please sign in to comment.