Skip to content

Commit

Permalink
infere keysource from keyvaultkeyid
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxu92 committed Mar 8, 2023
1 parent f9ef19e commit 7049d4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/services/automation/automation_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
Expand Down Expand Up @@ -77,7 +78,6 @@ func resourceAutomationAccount() *pluginsdk.Resource {
"key_source": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice(
automationaccount.PossibleValuesForEncryptionKeySourceType(),
false,
Expand Down Expand Up @@ -376,6 +376,7 @@ func expandEncryption(encMap map[string]interface{}) (*automationaccount.Encrypt
UserAssignedIdentity: &id,
},
}
prop.KeySource = pointer.To(automationaccount.EncryptionKeySourceTypeMicrosoftPointAutomation)
if val, ok := encMap["key_source"].(string); ok && val != "" {
prop.KeySource = (*automationaccount.EncryptionKeySourceType)(&val)
}
Expand All @@ -384,6 +385,9 @@ func expandEncryption(encMap map[string]interface{}) (*automationaccount.Encrypt
if err != nil {
return nil, err
}
if prop.KeySource == nil {
prop.KeySource = pointer.To(automationaccount.EncryptionKeySourceTypeMicrosoftPointKeyvault)
}
prop.KeyVaultProperties = &automationaccount.KeyVaultProperties{
KeyName: utils.String(keyId.Name),
KeyVersion: utils.String(keyId.Version),
Expand Down

0 comments on commit 7049d4b

Please sign in to comment.