Skip to content

Commit 8639071

Browse files
committed
Simplifying Storage Account Encryption creation
1 parent 3d6eed1 commit 8639071

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

pkg/infrastructure/azure/storage.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
"strings"
87
"sync"
98
"time"
109

@@ -462,7 +461,7 @@ func GenerateStorageAccountEncryption(ctx context.Context, in *CustomerManagedKe
462461

463462
keysClient = keyvaultClientFactory.NewKeysClient()
464463

465-
keysClientResponse, err := keysClient.Get(
464+
_, err = keysClient.Get(
466465
ctx,
467466
in.CustomerManagedKey.KeyVault.ResourceGroup,
468467
in.CustomerManagedKey.KeyVault.Name,
@@ -483,21 +482,15 @@ func GenerateStorageAccountEncryption(ctx context.Context, in *CustomerManagedKe
483482
return nil, fmt.Errorf("failed to get key vault %s which contains customer managed key: %w", in.CustomerManagedKey.KeyVault.Name, err)
484483
}
485484

486-
keyType := armstorage.KeyTypeAccount
487-
keySource := armstorage.KeySourceMicrosoftKeyvault
488-
489-
keyURIWithVersionSplit := strings.Split(*keysClientResponse.Key.Properties.KeyURIWithVersion, "/")
490-
versionPosition := len(keyURIWithVersionSplit) - 1
491-
492485
encryption := &armstorage.Encryption{
493486
Services: &armstorage.EncryptionServices{
494487
Blob: &armstorage.EncryptionService{
495488
Enabled: to.Ptr(true),
496-
KeyType: &keyType,
489+
KeyType: to.Ptr(armstorage.KeyTypeAccount),
497490
},
498491
File: &armstorage.EncryptionService{
499492
Enabled: to.Ptr(true),
500-
KeyType: &keyType,
493+
KeyType: to.Ptr(armstorage.KeyTypeAccount),
501494
},
502495
},
503496
EncryptionIdentity: &armstorage.EncryptionIdentity{
@@ -507,10 +500,10 @@ func GenerateStorageAccountEncryption(ctx context.Context, in *CustomerManagedKe
507500
in.CustomerManagedKey.UserAssignedIdentityKey,
508501
)),
509502
},
510-
KeySource: &keySource,
503+
KeySource: to.Ptr(armstorage.KeySourceMicrosoftKeyvault),
511504
KeyVaultProperties: &armstorage.KeyVaultProperties{
512-
KeyName: keysClientResponse.Key.Name,
513-
KeyVersion: &keyURIWithVersionSplit[versionPosition],
505+
KeyName: to.Ptr(in.CustomerManagedKey.KeyVault.KeyName),
506+
KeyVersion: to.Ptr(""),
514507
KeyVaultURI: keyVault.Properties.VaultURI,
515508
},
516509
}

0 commit comments

Comments
 (0)