Skip to content

Commit

Permalink
Change encryption at host to *bool
Browse files Browse the repository at this point in the history
  • Loading branch information
KMConner committed Sep 16, 2023
1 parent 3140920 commit 89e7794
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion builder/azure/arm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ type Config struct {
SecureBootEnabled bool `mapstructure:"secure_boot_enabled" required:"false"`
// Specifies if Encryption at host is enabled for the Virtual Machine.
// Requires enabling encryption at host in the Subscription read more [here](https://learn.microsoft.com/en-us/azure/virtual-machines/disks-enable-host-based-encryption-portal?tabs=azure-powershell)
EncryptionAtHost bool `mapstructure:"encryption_at_host" required:"false"`
EncryptionAtHost *bool `mapstructure:"encryption_at_host" required:"false"`

// Specifies if vTPM (virtual Trusted Platform Module) and Trusted Launch is enabled for the Virtual Machine.
VTpmEnabled bool `mapstructure:"vtpm_enabled" required:"false"`
Expand Down
2 changes: 1 addition & 1 deletion builder/azure/arm/template_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func GetVirtualMachineTemplateBuilder(config *Config) (*template.TemplateBuilder
}
}

if config.SecureBootEnabled || config.VTpmEnabled || config.EncryptionAtHost {
if config.SecureBootEnabled || config.VTpmEnabled || (config.EncryptionAtHost != nil && *config.EncryptionAtHost) {
err = builder.SetSecurityProfile(config.SecureBootEnabled, config.VTpmEnabled, config.EncryptionAtHost)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions builder/azure/common/template/template_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (s *TemplateBuilder) SetLicenseType(licenseType string) error {
return nil
}

func (s *TemplateBuilder) SetSecurityProfile(secureBootEnabled bool, vtpmEnabled bool, encryptionAtHost bool) error {
func (s *TemplateBuilder) SetSecurityProfile(secureBootEnabled bool, vtpmEnabled bool, encryptionAtHost *bool) error {
s.setVariable("apiVersion", "2020-12-01") // Required for Trusted Launch
resource, err := s.getResourceByType(resourceVirtualMachine)
if err != nil {
Expand All @@ -533,7 +533,7 @@ func (s *TemplateBuilder) SetSecurityProfile(secureBootEnabled bool, vtpmEnabled
resource.Properties.SecurityProfile.UefiSettings.SecureBootEnabled = common.BoolPtr(secureBootEnabled)
resource.Properties.SecurityProfile.UefiSettings.VTpmEnabled = common.BoolPtr(vtpmEnabled)
}
resource.Properties.SecurityProfile.EncryptionAtHost = common.BoolPtr(encryptionAtHost)
resource.Properties.SecurityProfile.EncryptionAtHost = encryptionAtHost

return nil
}
Expand Down

0 comments on commit 89e7794

Please sign in to comment.