@@ -190,6 +190,55 @@ func resourceSharedImageVersion() *pluginsdk.Resource {
190190 Default : false ,
191191 },
192192
193+ "uefi_settings" : {
194+ Type : pluginsdk .TypeList ,
195+ Optional : true ,
196+ ForceNew : true ,
197+ MaxItems : 1 ,
198+ Elem : & pluginsdk.Resource {
199+ Schema : map [string ]* pluginsdk.Schema {
200+ "signature_template_names" : {
201+ Type : pluginsdk .TypeSet ,
202+ Required : true ,
203+ Elem : & pluginsdk.Schema {
204+ Type : pluginsdk .TypeString ,
205+ ValidateFunc : validation .StringInSlice (galleryimageversions .PossibleValuesForUefiSignatureTemplateName (), false ),
206+ },
207+ },
208+ "additional_signatures" : {
209+ Type : pluginsdk .TypeList ,
210+ Optional : true ,
211+ MaxItems : 1 ,
212+ Elem : & pluginsdk.Resource {
213+ Schema : map [string ]* pluginsdk.Schema {
214+ "db" : {
215+ Type : pluginsdk .TypeList ,
216+ Optional : true ,
217+ Elem : uefiKeySchema (),
218+ },
219+ "dbx" : {
220+ Type : pluginsdk .TypeList ,
221+ Optional : true ,
222+ Elem : uefiKeySchema (),
223+ },
224+ "kek" : {
225+ Type : pluginsdk .TypeList ,
226+ Optional : true ,
227+ Elem : uefiKeySchema (),
228+ },
229+ "pk" : {
230+ Type : pluginsdk .TypeList ,
231+ Optional : true ,
232+ MaxItems : 1 ,
233+ Elem : uefiKeySchema (),
234+ },
235+ },
236+ },
237+ },
238+ },
239+ },
240+ },
241+
193242 "tags" : commonschema .Tags (),
194243 },
195244
@@ -236,7 +285,8 @@ func resourceSharedImageVersionCreate(d *pluginsdk.ResourceData, meta interface{
236285 SafetyProfile : & galleryimageversions.GalleryImageVersionSafetyProfile {
237286 AllowDeletionOfReplicatedLocations : utils .Bool (d .Get ("deletion_of_replicated_locations_enabled" ).(bool )),
238287 },
239- StorageProfile : galleryimageversions.GalleryImageVersionStorageProfile {},
288+ StorageProfile : galleryimageversions.GalleryImageVersionStorageProfile {},
289+ SecurityProfile : & galleryimageversions.ImageVersionSecurityProfile {},
240290 },
241291 Tags : tags .Expand (d .Get ("tags" ).(map [string ]interface {})),
242292 }
@@ -271,6 +321,10 @@ func resourceSharedImageVersionCreate(d *pluginsdk.ResourceData, meta interface{
271321 }
272322 }
273323
324+ if v , ok := d .GetOk ("uefi_settings" ); ok {
325+ version .Properties .SecurityProfile .UefiSettings = expandUefiSettings (v .([]interface {}))
326+ }
327+
274328 if err := client .CreateOrUpdateThenPoll (ctx , id , version ); err != nil {
275329 return fmt .Errorf ("creating %s: %+v" , id , err )
276330 }
@@ -330,6 +384,17 @@ func resourceSharedImageVersionUpdate(d *pluginsdk.ResourceData, meta interface{
330384 payload .Properties .PublishingProfile .ExcludeFromLatest = pointer .To (d .Get ("exclude_from_latest" ).(bool ))
331385 }
332386
387+ if d .HasChange ("uefi_settings" ) {
388+ if payload .Properties .SecurityProfile == nil {
389+ payload .Properties .SecurityProfile = & galleryimageversions.ImageVersionSecurityProfile {}
390+ }
391+ if v , ok := d .GetOk ("uefi_settings" ); ok {
392+ payload .Properties .SecurityProfile .UefiSettings = expandUefiSettings (v .([]interface {}))
393+ } else {
394+ payload .Properties .SecurityProfile .UefiSettings = nil
395+ }
396+ }
397+
333398 if d .HasChange ("tags" ) {
334399 payload .Tags = tags .Expand (d .Get ("tags" ).(map [string ]interface {}))
335400 }
@@ -416,6 +481,16 @@ func resourceSharedImageVersionRead(d *pluginsdk.ResourceData, meta interface{})
416481 if safetyProfile := props .SafetyProfile ; safetyProfile != nil {
417482 d .Set ("deletion_of_replicated_locations_enabled" , pointer .From (safetyProfile .AllowDeletionOfReplicatedLocations ))
418483 }
484+
485+ if securityProfile := props .SecurityProfile ; securityProfile != nil {
486+ if uefiSettings := securityProfile .UefiSettings ; uefiSettings != nil {
487+ d .Set ("uefi_settings" , flattenUefiSettings (uefiSettings ))
488+ } else {
489+ d .Set ("uefi_settings" , nil )
490+ }
491+ } else {
492+ d .Set ("uefi_settings" , nil )
493+ }
419494 }
420495 return tags .FlattenAndSet (d , model .Tags )
421496 }
@@ -511,6 +586,209 @@ func expandSharedImageVersionTargetRegions(d *pluginsdk.ResourceData) (*[]galler
511586 return & results , nil
512587}
513588
589+ func uefiKeySchema () * pluginsdk.Resource {
590+ return & pluginsdk.Resource {
591+ Schema : map [string ]* pluginsdk.Schema {
592+ "certificate_base64" : {
593+ Type : pluginsdk .TypeList ,
594+ Required : true ,
595+ Elem : & pluginsdk.Schema {
596+ Type : pluginsdk .TypeString ,
597+ },
598+ },
599+ "type" : {
600+ Type : pluginsdk .TypeString ,
601+ Required : true ,
602+ ValidateFunc : validation .StringInSlice (galleryimageversions .PossibleValuesForUefiKeyType (), false ),
603+ },
604+ },
605+ }
606+ }
607+
608+ func expandUefiSettings (input []interface {}) * galleryimageversions.GalleryImageVersionUefiSettings {
609+ if len (input ) == 0 || input [0 ] == nil {
610+ return nil
611+ }
612+
613+ v := input [0 ].(map [string ]interface {})
614+ result := & galleryimageversions.GalleryImageVersionUefiSettings {}
615+
616+ if templateNamesSet , ok := v ["signature_template_names" ].(* pluginsdk.Set ); ok {
617+ result .SignatureTemplateNames = expandSignatureTemplateNames (templateNamesSet .List ())
618+ }
619+
620+ if additionalSignatures , ok := v ["additional_signatures" ].([]interface {}); ok {
621+ result .AdditionalSignatures = expandAdditionalSignatures (additionalSignatures )
622+ }
623+
624+ return result
625+ }
626+
627+ func expandSignatureTemplateNames (input []interface {}) * []galleryimageversions.UefiSignatureTemplateName {
628+ if len (input ) == 0 {
629+ return nil
630+ }
631+
632+ result := make ([]galleryimageversions.UefiSignatureTemplateName , 0 )
633+ for _ , v := range input {
634+ result = append (result , galleryimageversions .UefiSignatureTemplateName (v .(string )))
635+ }
636+ return & result
637+ }
638+
639+ func expandAdditionalSignatures (input []interface {}) * galleryimageversions.UefiKeySignatures {
640+ if len (input ) == 0 || input [0 ] == nil {
641+ return nil
642+ }
643+
644+ v := input [0 ].(map [string ]interface {})
645+ result := & galleryimageversions.UefiKeySignatures {}
646+
647+ if db , ok := v ["db" ].([]interface {}); ok {
648+ result .Db = expandUefiKeyList (db )
649+ }
650+
651+ if dbx , ok := v ["dbx" ].([]interface {}); ok {
652+ result .Dbx = expandUefiKeyList (dbx )
653+ }
654+
655+ if kek , ok := v ["kek" ].([]interface {}); ok {
656+ result .Kek = expandUefiKeyList (kek )
657+ }
658+
659+ if pk , ok := v ["pk" ].([]interface {}); ok {
660+ result .Pk = expandSingleUefiKey (pk )
661+ }
662+
663+ return result
664+ }
665+
666+ func expandUefiKeyList (input []interface {}) * []galleryimageversions.UefiKey {
667+ if len (input ) == 0 {
668+ return nil
669+ }
670+
671+ result := make ([]galleryimageversions.UefiKey , 0 )
672+ for _ , v := range input {
673+ result = append (result , expandUefiKey (v .(map [string ]interface {})))
674+ }
675+ return & result
676+ }
677+
678+ func expandSingleUefiKey (input []interface {}) * galleryimageversions.UefiKey {
679+ if len (input ) == 0 {
680+ return nil
681+ }
682+
683+ data := input [0 ].(map [string ]interface {})
684+ return & galleryimageversions.UefiKey {
685+ Type : pointer .To (galleryimageversions .UefiKeyType (data ["type" ].(string ))),
686+ Value : & []string {data ["certificate_base64" ].(string )},
687+ }
688+ }
689+
690+ func expandUefiKey (input map [string ]interface {}) galleryimageversions.UefiKey {
691+ result := galleryimageversions.UefiKey {
692+ Value : & []string {},
693+ }
694+
695+ if certList , ok := input ["certificate_base64" ].([]interface {}); ok {
696+ certData := make ([]string , 0 )
697+ for _ , item := range certList {
698+ if str , ok := item .(string ); ok {
699+ certData = append (certData , str )
700+ }
701+ }
702+ result .Value = & certData
703+ }
704+
705+ if typeStr , ok := input ["type" ].(string ); ok {
706+ result .Type = pointer .To (galleryimageversions .UefiKeyType (typeStr ))
707+ }
708+
709+ return result
710+ }
711+
712+ func flattenUefiSettings (input * galleryimageversions.GalleryImageVersionUefiSettings ) []interface {} {
713+ results := make ([]interface {}, 0 )
714+
715+ if input == nil {
716+ return results
717+ }
718+
719+ results = append (results , map [string ]interface {}{
720+ "signature_template_names" : pointer .From (input .SignatureTemplateNames ),
721+ "additional_signatures" : flattenAdditionalSignatures (input .AdditionalSignatures ),
722+ })
723+
724+ return results
725+ }
726+
727+ func flattenAdditionalSignatures (input * galleryimageversions.UefiKeySignatures ) []interface {} {
728+ results := make ([]interface {}, 0 )
729+
730+ if input == nil {
731+ return results
732+ }
733+
734+ result := make (map [string ]interface {})
735+ result ["db" ] = flattenUefiKeyList (input .Db )
736+ result ["dbx" ] = flattenUefiKeyList (input .Dbx )
737+ result ["kek" ] = flattenUefiKeyList (input .Kek )
738+ result ["pk" ] = flattenSingleUefiKey (input .Pk )
739+
740+ return append (results , result )
741+ }
742+
743+ func flattenSingleUefiKey (input * galleryimageversions.UefiKey ) []interface {} {
744+ results := make ([]interface {}, 0 )
745+ if input == nil {
746+ return results
747+ }
748+
749+ result := make (map [string ]interface {})
750+ if input .Value != nil && len (* input .Value ) > 0 {
751+ result ["certificate_base64" ] = (* input .Value )[0 ]
752+ }
753+ if input .Type != nil {
754+ result ["type" ] = pointer .From (input .Type )
755+ }
756+
757+ return append (results , result )
758+ }
759+
760+ func flattenUefiKeyList (input * []galleryimageversions.UefiKey ) []interface {} {
761+ results := make ([]interface {}, 0 )
762+ if input == nil {
763+ return results
764+ }
765+
766+ for _ , v := range * input {
767+ if item := flattenUefiKey (& v ); len (item ) > 0 {
768+ results = append (results , item [0 ])
769+ }
770+ }
771+
772+ return results
773+ }
774+
775+ func flattenUefiKey (input * galleryimageversions.UefiKey ) []interface {} {
776+ results := make ([]interface {}, 0 )
777+ if input == nil {
778+ return results
779+ }
780+
781+ result := make (map [string ]interface {})
782+ if input .Value != nil && len (* input .Value ) > 0 {
783+ result ["certificate_base64" ] = (* input .Value )[0 ]
784+ }
785+ if input .Type != nil {
786+ result ["type" ] = pointer .From (input .Type )
787+ }
788+
789+ return append (results , result )
790+ }
791+
514792func flattenSharedImageVersionTargetRegions (input * []galleryimageversions.TargetRegion ) []interface {} {
515793 results := make ([]interface {}, 0 )
516794
0 commit comments