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_disk_encryption_set: Support for the managed_hsm_key_id property #26201

Merged
merged 9 commits into from
Jun 28, 2024
13 changes: 12 additions & 1 deletion internal/services/compute/disk_encryption_set_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
managedHsmHelpers "github.com/hashicorp/terraform-provider-azurerm/internal/services/managedhsm/helpers"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
Expand Down Expand Up @@ -58,6 +59,7 @@ func dataSourceDiskEncryptionSet() *pluginsdk.Resource {

func dataSourceDiskEncryptionSetRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Compute.DiskEncryptionSetsClient
env := meta.(*clients.Client).Account.Environment
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand All @@ -84,7 +86,16 @@ func dataSourceDiskEncryptionSetRead(d *pluginsdk.ResourceData, meta interface{}
d.Set("auto_key_rotation_enabled", props.RotationToLatestKeyVersionEnabled)

if props.ActiveKey != nil && props.ActiveKey.KeyUrl != "" {
d.Set("key_vault_key_url", props.ActiveKey.KeyUrl)
keyVaultURI := props.ActiveKey.KeyUrl
isHSMURI, err, _, _ := managedHsmHelpers.IsManagedHSMURI(env, keyVaultURI)
katbyte marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return fmt.Errorf("Parshing key vault URI: %+v", err)
}
if isHSMURI {
d.Set("managed_hsm_key_id", keyVaultURI)
} else {
d.Set("key_vault_key_url", keyVaultURI)
}
}
}

Expand Down
Loading
Loading