@@ -307,7 +307,7 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
307307
308308 imageLength := headResponse .ContentLength
309309 if imageLength % 512 != 0 {
310- return fmt .Errorf ("image length is not alisnged on a 512 byte boundary" )
310+ return fmt .Errorf ("image length is not aligned on a 512 byte boundary" )
311311 }
312312
313313 userTags := platform .UserTags
@@ -329,6 +329,7 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
329329 CloudName : platform .CloudName ,
330330 Region : platform .Region ,
331331 Tags : tags ,
332+ CustomerManagedKey : platform .CustomerManagedKey ,
332333 TokenCredential : tokenCredential ,
333334 CloudConfiguration : cloudConfiguration ,
334335 })
@@ -343,11 +344,16 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
343344 logrus .Debugf ("StorageAccount.ID=%s" , * storageAccount .ID )
344345
345346 // Create blob storage container
347+ publicAccess := armstorage .PublicAccessContainer
348+ if platform .CustomerManagedKey != nil {
349+ publicAccess = armstorage .PublicAccessNone
350+ }
346351 createBlobContainerOutput , err := CreateBlobContainer (ctx , & CreateBlobContainerInput {
347352 SubscriptionID : subscriptionID ,
348353 ResourceGroupName : resourceGroupName ,
349354 StorageAccountName : storageAccountName ,
350355 ContainerName : containerName ,
356+ PublicAccess : to .Ptr (publicAccess ),
351357 StorageClientFactory : storageClientFactory ,
352358 })
353359 if err != nil {
@@ -760,13 +766,17 @@ func (p Provider) Ignition(ctx context.Context, in clusterapi.IgnitionInput) ([]
760766 ignitionContainerName := "ignition"
761767 blobName := "bootstrap.ign"
762768 blobURL := fmt .Sprintf ("%s/%s/%s" , p .StorageURL , ignitionContainerName , blobName )
763-
769+ publicAccess := armstorage .PublicAccessContainer
770+ if in .InstallConfig .Config .Azure .CustomerManagedKey != nil {
771+ publicAccess = armstorage .PublicAccessNone
772+ }
764773 // Create ignition blob storage container
765774 createBlobContainerOutput , err := CreateBlobContainer (ctx , & CreateBlobContainerInput {
766775 ContainerName : ignitionContainerName ,
767776 SubscriptionID : subscriptionID ,
768777 ResourceGroupName : p .ResourceGroupName ,
769778 StorageAccountName : p .StorageAccountName ,
779+ PublicAccess : to .Ptr (publicAccess ),
770780 StorageClientFactory : p .StorageClientFactory ,
771781 })
772782 if err != nil {
@@ -776,16 +786,41 @@ func (p Provider) Ignition(ctx context.Context, in clusterapi.IgnitionInput) ([]
776786 blobIgnitionContainer := createBlobContainerOutput .BlobContainer
777787 logrus .Debugf ("BlobIgnitionContainer.ID=%s" , * blobIgnitionContainer .ID )
778788
779- sasURL , err := CreateBlockBlob (ctx , & CreateBlockBlobInput {
780- StorageURL : p .StorageURL ,
781- BlobURL : blobURL ,
782- StorageAccountName : p .StorageAccountName ,
783- StorageAccountKeys : p .StorageAccountKeys ,
784- CloudConfiguration : cloudConfiguration ,
785- BootstrapIgnData : bootstrapIgnData ,
786- })
787- if err != nil {
788- return nil , err
789+ sasURL := ""
790+
791+ if in .InstallConfig .Config .Azure .CustomerManagedKey == nil {
792+ logrus .Debugf ("Creating a Block Blob for ignition shim" )
793+ sasURL , err = CreateBlockBlob (ctx , & CreateBlockBlobInput {
794+ StorageURL : p .StorageURL ,
795+ BlobURL : blobURL ,
796+ StorageAccountName : p .StorageAccountName ,
797+ StorageAccountKeys : p .StorageAccountKeys ,
798+ CloudConfiguration : cloudConfiguration ,
799+ BootstrapIgnData : bootstrapIgnData ,
800+ })
801+ if err != nil {
802+ return nil , fmt .Errorf ("failed to create BlockBlob for ignition shim: %w" , err )
803+ }
804+ } else {
805+ logrus .Debugf ("Creating a Page Blob for ignition shim because Customer Managed Key is provided" )
806+ lengthBootstrapFile := int64 (len (bootstrapIgnData ))
807+ if lengthBootstrapFile % 512 != 0 {
808+ lengthBootstrapFile = (((lengthBootstrapFile / 512 ) + 1 ) * 512 )
809+ }
810+
811+ sasURL , err = CreatePageBlob (ctx , & CreatePageBlobInput {
812+ StorageURL : p .StorageURL ,
813+ BlobURL : blobURL ,
814+ ImageURL : "" ,
815+ StorageAccountName : p .StorageAccountName ,
816+ BootstrapIgnData : bootstrapIgnData ,
817+ ImageLength : lengthBootstrapFile ,
818+ StorageAccountKeys : p .StorageAccountKeys ,
819+ CloudConfiguration : cloudConfiguration ,
820+ })
821+ if err != nil {
822+ return nil , fmt .Errorf ("failed to create PageBlob for ignition shim: %w" , err )
823+ }
789824 }
790825 ignShim , err := bootstrap .GenerateIgnitionShimWithCertBundleAndProxy (sasURL , in .InstallConfig .Config .AdditionalTrustBundle , in .InstallConfig .Config .Proxy )
791826 if err != nil {
0 commit comments