Skip to content

Commit

Permalink
add new HSM Key recovery feature option
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops committed May 24, 2024
1 parent 881f636 commit f29d632
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/provider/framework/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ func (p *ProviderConfig) Load(ctx context.Context, data *ProviderModel, tfVersio
if !feature[0].RecoverSoftDeletedSecrets.IsNull() && !feature[0].RecoverSoftDeletedSecrets.IsUnknown() {
f.KeyVault.RecoverSoftDeletedSecrets = feature[0].RecoverSoftDeletedSecrets.ValueBool()
}

f.KeyVault.RecoverSoftDeletedHSMKeys = true
if !feature[0].RecoverSoftDeletedHSMKeys.IsNull() && !feature[0].RecoverSoftDeletedHSMKeys.IsUnknown() {
f.KeyVault.RecoverSoftDeletedHSMKeys = feature[0].RecoverSoftDeletedHSMKeys.ValueBool()
}
} else {
f.KeyVault.PurgeSoftDeleteOnDestroy = true
f.KeyVault.PurgeSoftDeletedCertsOnDestroy = true
Expand All @@ -420,6 +425,7 @@ func (p *ProviderConfig) Load(ctx context.Context, data *ProviderModel, tfVersio
f.KeyVault.RecoverSoftDeletedKeyVaults = true
f.KeyVault.RecoverSoftDeletedKeys = true
f.KeyVault.RecoverSoftDeletedSecrets = true
f.KeyVault.RecoverSoftDeletedHSMKeys = true
}

if !features.LogAnalyticsWorkspace.IsNull() && !features.LogAnalyticsWorkspace.IsUnknown() {
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/framework/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func TestProviderConfig_LoadDefault(t *testing.T) {
t.Errorf("expected key_vault.recover_soft_deleted_secrets to be true")
}

if !features.KeyVault.RecoverSoftDeletedHSMKeys {
t.Errorf("expected key_vault.recover_soft_deleted_hsm_keys to be true")
}

if !features.LogAnalyticsWorkspace.PermanentlyDeleteOnDestroy {
t.Errorf("expected log_analytics_workspace.permanently_delete_on_destroy to be true")
}
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/framework/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ type KeyVault struct {
RecoverSoftDeletedKeyVaults types.Bool `tfsdk:"recover_soft_deleted_key_vaults"`
RecoverSoftDeletedKeys types.Bool `tfsdk:"recover_soft_deleted_keys"`
RecoverSoftDeletedSecrets types.Bool `tfsdk:"recover_soft_deleted_secrets"`
RecoverSoftDeletedHSMKeys types.Bool `tfsdk:"recover_soft_deleted_hardware_security_module_keys"`
}

var KeyVaultAttributes = map[string]attr.Type{
Expand All @@ -135,6 +136,7 @@ var KeyVaultAttributes = map[string]attr.Type{
"recover_soft_deleted_key_vaults": types.BoolType,
"recover_soft_deleted_keys": types.BoolType,
"recover_soft_deleted_secrets": types.BoolType,
"recover_soft_deleted_hardware_security_module_keys": types.BoolType,
}

type LogAnalyticsWorkspace struct {
Expand Down

0 comments on commit f29d632

Please sign in to comment.